*/ class Ahime_Image_Printer_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; } /** * 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 Ahime_Image_Printer_Loader as all of the hooks are defined * in that particular class. * * The Ahime_Image_Printer_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/ahime-image-printer-admin.css', array(), $this->version, 'all' ); } /** * Register the JavaScript for the admin area. * * @since 1.0.0 */ public function enqueue_scripts() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Ahime_Image_Printer_Loader as all of the hooks are defined * in that particular class. * * The Ahime_Image_Printer_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/ahime-image-printer-admin.js', array( 'jquery' ), $this->version, false ); wp_localize_script( $this->plugin_name, 'ahime', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), ) ); } /** * Add admin menu. * * @return void */ public function add_submenu() { if ( class_exists( 'WooCommerce' ) ) { $icon = AHIME_URL . 'admin/assets/images/resize_ahime.png'; add_menu_page( __( 'Ahime', 'ahime-image-printer' ), __( 'Ahime', 'ahime-image-printer' ), 'manage_options', 'image-printing-setting', array( $this, 'set_admin_setting_content' ), $icon, 10 ); } } /** * Set admin settings content. * * @return void */ public function set_admin_setting_content() { $page_id = get_all_page_ids(); $defined_page_id = get_option( 'ahime-page', false ); ?>

get_type() ) { return; } echo wp_kses_post( $this->get_variation_product_config_selector( null, null, $product ) ); } /** * Get product selector. * * @param mixed $loop Loop item. * @param array $variation_data Variation data. * @param mixed $variation Variation. * @return void */ public function get_variation_product_config_selector( $loop, $variation_data, $variation ) { if ( isset( $variation->ID ) ) { $variation_id = $variation->ID; } else { $variation_id = $variation->get_id(); } if ( isset( $variation->post_type ) ) { $product_type = $variation->post_type; } else { $product_type = $variation->get_type(); } $post_meta = get_post_meta( $variation_id, 'ahime-image', false ); if ( ! empty( $post_meta ) ) { $post_meta = $post_meta[ array_key_last( $post_meta ) ]; $config = true; } else { $config = false; } ?>

__( 'The configurator page has been added', 'ahime-image-printer' ), 'success' => true, ); } else { $msg = array( 'msg' => __( 'An error has occurred. The page could not be added', 'ahime-image-printer' ), 'success' => false, ); } echo wp_json_encode( $msg ); die; } /** * Alerts the administrator if the minimum requirements are not met. */ public function notify_prerequisites() { global $atd_settings; $minimum_required_parameters = array( 'memory_limit' => array( 128, 'M' ), 'post_max_size' => array( 8, 'M' ), 'upload_max_filesize' => array( 32, 'M' ), ); $messages = array(); $image_page_id = get_option( 'ahime-page', false ); $settings_url = get_bloginfo( 'url' ) . '/wp-admin/admin.php?page=image-printing-setting'; $permalinks_structure = get_option( 'permalink_structure' ); if ( ! class_exists( 'WooCommerce' ) ) { $messages[] = 'WooCommerce is not installed on your website. You will not be able to use the features of the plugin'; } elseif ( empty( $image_page_id ) ) { $messages[] = "The design page is not defined. Please set one here plugin settings page: .

"; } elseif ( ! extension_loaded( 'zip' ) ) { $messages[] = "ZIP extension not loaded on this server. You won't be able to generate zip outputs.

"; } foreach ( $minimum_required_parameters as $key => $min_arr ) { $defined_value = ini_get( $key ); if ( ! stristr( $defined_value, 'G', true ) ) { $defined_value_int = str_replace( $min_arr[1], '', $defined_value ); if ( $defined_value_int < $min_arr[0] && -1 !== $defined_value_int ) { $messages[] = "Your PHP setting $key is currently set to $defined_value. We recommand to set this value at least to " . implode( '', $min_arr ) . ' to avoid any issue with our plugin.

' . esc_html__( 'How to fix this: You can edit your php.ini file to increase the specified variables to the recommanded values or you can ask your hosting company to make the changes for you.', 'atd' ) . ''; } } } if ( strpos( $permalinks_structure, 'index.php' ) !== false ) { $message .= 'Your permalinks structure is currently set to custom with index.php present in the structure. We recommand to set this value to Post name to avoid any issue with our plugin.
'; } if ( isset( $messages ) && ! empty( $messages ) ) { foreach ( $messages as $key => $message ) { ?>

: