/** * Initialization function, similar to __construct() * * This function contains add_action and add_filter calls * to set up the Ajax handlers, enqueue JavaScript and CSS files, and * set up the Assistant submenu. * * @since 0.1 * * @return void */ public static function initialize() { global $sitepress, $polylang; if ('checked' == MLAOptions::mla_get_option('enable_featured_image_generation')) { if (class_exists('MLA_Thumbnail')) { self::$mla_language_support_error_messages .= "<li>class MLA_Thumbnail</li>"; } else { require_once MLA_PLUGIN_PATH . 'includes/class-mla-thumbnail-generation.php'; MLA_Thumbnail::initialize(); } } /* * Check for WPML/Polylang presence before loading language support class, * then immediately initialize it since we're already in the "init" action. */ if (is_object($sitepress)) { if (class_exists('MLA_WPML')) { self::$mla_language_support_error_messages .= "<li>class MLA_WPML</li>"; } if (class_exists('MLA_WPML_List_Table')) { self::$mla_language_support_error_messages .= "<li>class MLA_WPML_List_Table</li>"; } if (class_exists('MLA_WPML_Table')) { self::$mla_language_support_error_messages .= "<li>class MLA_WPML_Table</li>"; } if (empty(self::$mla_language_support_error_messages)) { require_once MLA_PLUGIN_PATH . 'includes/class-mla-wpml-support.php'; MLA_WPML::initialize(); } } elseif (is_object($polylang)) { if (class_exists('MLAPolylangSupport')) { self::$mla_language_support_error_messages .= '<li>class MLAPolylangSupport in plugin "MLA Polylang Support"</li>'; } if (class_exists('MLA_Polylang')) { self::$mla_language_support_error_messages .= "<li>class MLA_Polylang</li>"; } if (empty(self::$mla_language_support_error_messages)) { require_once MLA_PLUGIN_PATH . 'includes/class-mla-polylang-support.php'; MLA_Polylang::initialize(); } } if (!empty(self::$mla_language_support_error_messages)) { add_action('admin_notices', 'MLA::mla_name_conflict_reporting_action'); } add_action('admin_init', 'MLA::mla_admin_init_action'); add_action('admin_enqueue_scripts', 'MLA::mla_admin_enqueue_scripts_action'); add_action('admin_menu', 'MLA::mla_admin_menu_action'); add_filter('set-screen-option', 'MLA::mla_set_screen_option_filter', 10, 3); // $status, $option, $value add_filter('screen_options_show_screen', 'MLA::mla_screen_options_show_screen_filter', 10, 2); // $show_screen, $this }
/** * Begin an MLA_List_Table bulk action * * Prepare the thumbnail generation options. * * @since 2.13 * * @param array $item_content NULL, to indicate no handler. * @param string $bulk_action the requested action. */ public static function mla_list_table_begin_bulk_action($item_content, $bulk_action) { if (self::MLA_GFI_ACTION != $bulk_action) { return $item_content; } self::$bulk_action_options = array(); $request_options = isset($_REQUEST['mla_thumbnail_options']) ? $_REQUEST['mla_thumbnail_options'] : array(); $request_options['ghostscript_path'] = MLAOptions::mla_get_option('ghostscript_path'); if (empty($request_options['existing_thumbnails'])) { $request_options['existing_thumbnails'] = 'keep'; } foreach ($request_options as $key => $value) { if (!empty($value)) { self::$bulk_action_options[$key] = $value; } } // Convert checkboxes to booleans self::$bulk_action_options['best_fit'] = isset($request_options['best_fit']); self::$bulk_action_options['clear_filters'] = isset($request_options['clear_filters']); // Convert page number to frame if (isset(self::$bulk_action_options['page'])) { $page = abs(intval(self::$bulk_action_options['page'])); self::$bulk_action_options['frame'] = 0 < $page ? $page - 1 : 0; unset(self::$bulk_action_options['page']); } return $item_content; }