PATH:
home
/
letacommog
/
winwithd
/
wp-content
/
plugins
/
paid-member-subscriptions
/
includes
<?php // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) exit; Class PMS_Meta_Box { /** * Meta box id * * @access public * @var string */ public $id; /** * Meta box title * * @access public * @var string */ public $title; /** * Post type to assign * * @access public * @var string */ public $post_type; /** * Meta box position * * @access public * @var string */ public $context; /** * Meta fields keys and a set of default values * * @access public * @var array */ public $meta_default_values = array(); /* * Constructor * */ public function __construct( $id = '', $title ='', $post_type = '', $context = 'advanced' ) { $this->id = $id; $this->title = $title; $this->post_type = $post_type; $this->context = $context; if( $this->post_type == pms_get_current_post_type() ) { add_action( 'add_meta_boxes' , array( $this, 'remove_meta_boxes' ) ); add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) ); // Enqueue scripts if( is_admin() ) add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) ); } // Save posts, pages and custom post types add_action( 'save_post', array( $this, 'save_meta_box' ), 10, 2 ); // Save attachments, which are handled different in the WP core add_action( 'attachment_updated', array( $this, 'save_meta_box' ), 10, 2 ); } /* * Method to remove certain meta boxes that are not needed * */ public function remove_meta_boxes() { $removable_meta_boxes_post_types = array( 'pms-subscription' ); if( in_array( $this->post_type, $removable_meta_boxes_post_types ) ) remove_meta_box('slugdiv', $this->post_type, 'normal'); } /* * Method that adds the meta box * */ public function add_meta_box() { add_meta_box( $this->id, $this->title, array( $this, 'output_content' ), $this->post_type, $this->context ); } /* * Method to display content in the meta-box * */ public function output_content( $post ) { // Action to output content before default meta-box content do_action( 'pms_output_content_meta_box_' . $this->post_type . '_' . $this->id . '_before', $post ); // Action to output default meta-box content do_action( 'pms_output_content_meta_box_' . $this->post_type . '_' . $this->id, $post ); // Action to output content after default meta-box content do_action( 'pms_output_content_meta_box_' . $this->post_type . '_' . $this->id . '_after', $post ); } /* * Method returns the post meta with default values if they are not set * */ public function get_post_meta( $post, $default_values = array() ) { $post_meta = pms_get_post_meta( $post->ID ); if( !empty( $default_values ) ) { foreach( $default_values as $meta_key => $default_value ) { if( !isset( $post_meta[ $meta_key ] ) ) { $post_meta[ $meta_key ] = $default_value; } } } return $post_meta; } /* * Method that saves the meta box data * */ public function save_meta_box( $post_id, $post ) { /* * Must verify nonce */ // Skip if there's an auto-save going on if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $post_id; do_action( 'pms_save_meta_box_' . $this->post_type, $post_id, $post ); } /* * Method to enqueue scripts on the admin side * It enqueues files based on a sanitized string from the meta-box id * */ public function enqueue_admin_scripts() { $screen = get_current_screen(); if( $screen->id != $this->post_type ) return; // Sanitize the filename by removing the prefix and changing the underscores to dashes $js_file_name = 'meta-box-' . str_replace( '_', '-', str_replace( 'pms_', '', $this->id ) ) . '.js'; // If the file exists where it should be, enqueue it if( file_exists( PMS_PLUGIN_DIR_PATH . 'assets/js/admin/' . $js_file_name ) ) wp_enqueue_script( $this->id . '-js', PMS_PLUGIN_DIR_URL . 'assets/js/admin/' . $js_file_name, array( 'jquery' ) ); do_action( 'pms_meta_box_enqueue_admin_scripts_' . $this->id ); } }
[+]
..
[-] functions-content-filtering.php
[edit]
[-] functions-logger.php
[edit]
[-] class-notices.php
[edit]
[+]
views
[-] class-member.php
[edit]
[-] class-emails.php
[edit]
[-] class-shortcodes.php
[edit]
[-] functions-form-extra-fields.php
[edit]
[-] functions-subscription-plan.php
[edit]
[-] class-member-subscription.php
[edit]
[-] deprecated-functions.php
[edit]
[-] functions-plugin-compatibilities.php
[edit]
[-] functions-member-subscriptions.php
[edit]
[+]
modules
[-] class-form-handler.php
[edit]
[-] class-merge-tags.php
[edit]
[-] functions-content-restriction.php
[edit]
[-] functions-user-roles.php
[edit]
[+]
admin
[-] functions-page.php
[edit]
[-] functions-core.php
[edit]
[-] functions-backwards-compatibility.php
[edit]
[-] functions-user.php
[edit]
[-] class-success.php
[edit]
[-] functions-member.php
[edit]
[-] class-custom-post-types.php
[edit]
[-] functions-payment.php
[edit]
[-] class-uninstaller.php
[edit]
[+]
gateways
[-] functions-plugin-notifications.php
[edit]
[-] class-subscription-plan.php
[edit]
[-] class-plugin-notifications.php
[edit]
[-] functions-utils.php
[edit]
[-] class-plugin-usage-tracker.php
[edit]
[-] class-payment.php
[edit]
[-] class-billing-details.php
[edit]
[-] class-meta-boxes.php
[edit]
[-] class-submenu-page.php
[edit]