*/ class Wc_Atcbm_Admin { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; } /** * Add link to plugin page * * @access public * @param array, string * @return array * */ public function add_support_link($links, $file){ if(!current_user_can('install_plugins')){ return $links; } if($file == 'wc-atcbm/wc-atcbm.php'){ $links[] = ''.__('Docs', 'wc-atcbm').''; $links[] = ''.__('Support', 'wc-atcbm').''; $links[] = ''.__('More WooCommerce Extensions', 'wc-atcbm').''; } return $links; } /** * Register the stylesheets for the admin area. * * @since 1.0.0 */ public function enqueue_styles() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Wc_Atcbm_Loader as all of the hooks are defined * in that particular class. * * The Wc_Atcbm_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wc-atcbm-admin.css', array(), $this->version, 'all' ); } /** * Register the JavaScript for the admin area. * * @since 1.0.0 */ public function enqueue_scripts($hook) { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Wc_Atcbm_Loader as all of the hooks are defined * in that particular class. * * The Wc_Atcbm_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ if ( $hook == 'post-new.php' || $hook == 'post.php' ) { if( 'product' == get_post_type() ){ wp_enqueue_script( 'timepicker-addon', plugin_dir_url( __FILE__ ) . '/js/jquery-ui-timepicker-addon.js', array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker'), $this->version, true ); wp_enqueue_style( 'jquery-ui-datepicker' ); wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wc-atcbm-admin.js',array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker','timepicker-addon'), $this->version, false ); } } } /** * Add lottery setings tab to woocommerce setings page * * @access public * */ function atcbm_settings_class($settings){ $settings[] = include( plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wc-atcbm-settings.php' ); return $settings; } /** * Add options to product advanced options * * @since 1.0.0 */ public function add_options_to_product() { global $post; echo '
'; } /** * Saves the data entered into the product boxes, as post meta data * * * @param int $post_id the post (product) identifier * @param stdClass $post the post (product) * */ public function product_save_data($post_id, $post){ if (isset($_POST['_wc_atcbm_disable_add_to_cart_button'] )){ update_post_meta( $post_id, '_wc_atcbm_disable_add_to_cart_button', wc_clean( $_POST['_wc_atcbm_disable_add_to_cart_button'] ) ); } else { update_post_meta( $post_id, '_wc_atcbm_disable_add_to_cart_button', 'no' ); } if (isset($_POST['_wc_atcbm_hide_price'] )){ update_post_meta( $post_id, '_wc_atcbm_hide_price', wc_clean( $_POST['_wc_atcbm_hide_price'] ) ); } else { update_post_meta( $post_id, '_wc_atcbm_hide_price', 'no' ); } if (isset($_POST['_wc_atcbm_button_dates_from'] )){ update_post_meta( $post_id, '_wc_atcbm_button_dates_from', wc_clean( $_POST['_wc_atcbm_button_dates_from'] ) ); } else { delete_post_meta( $post_id, '_wc_atcbm_button_dates_from'); } if (isset($_POST['_wc_atcbm_button_dates_to'] )){ update_post_meta( $post_id, '_wc_atcbm_button_dates_to', wc_clean( $_POST['_wc_atcbm_button_dates_to'] ) ); } else { delete_post_meta( $post_id, '_wc_atcbm_button_dates_to'); } } }