/** * Initialization function, similar to __construct() * * @since 0.60 * * @return void */ public static function initialize() { MLATest::$wp_3dot5 = version_compare(get_bloginfo('version'), '3.5.0', '>=') && version_compare(get_bloginfo('version'), '3.5.99', '<='); MLATest::$wp_4dot3_plus = version_compare(get_bloginfo('version'), '4.2.99', '>='); /* * This is the earliest effective place to change error_reporting */ MLACore::$original_php_log = ini_get('error_log'); MLACore::$original_php_reporting = sprintf('0x%1$04X', error_reporting()); $php_reporting = trim(MLACore::mla_get_option(MLACoreOptions::MLA_DEBUG_REPLACE_PHP_REPORTING)); if (!empty($php_reporting)) { @error_reporting(0 + $php_reporting); } /* * This is the earliest effective place to localize values in other plugin components */ MLACoreOptions::mla_localize_option_definitions_array(); if (class_exists('MLASettings')) { MLASettings::mla_localize_tablist(); } if (class_exists('MLAQuery')) { MLAQuery::mla_localize_default_columns_array(); } if (class_exists('MLA_Upload_List_Table')) { MLA_Upload_List_Table::mla_localize_default_columns_array(); } if (class_exists('MLA_Upload_Optional_List_Table')) { MLA_Upload_Optional_List_Table::mla_localize_default_columns_array(); } if (class_exists('MLA_View_List_Table')) { MLA_View_List_Table::mla_localize_default_columns_array(); } }
/** * Initialization function, similar to __construct() * * @since 0.60 * * @return void */ public static function initialize() { MLATest::$wp_3dot5 = version_compare(get_bloginfo('version'), '3.5.0', '>=') && version_compare(get_bloginfo('version'), '3.5.99', '<='); MLATest::$wp_4dot3_plus = version_compare(get_bloginfo('version'), '4.2.99', '>='); /* * This is the earliest effective place to change error_reporting */ //error_reporting( E_ALL | E_STRICT | E_DEPRECATED | E_USER_DEPRECATED | E_USER_ERROR | E_USER_WARNING ); //error_reporting( E_ALL | E_STRICT ); MLA::$original_php_reporting = sprintf('0x%1$04X', error_reporting()); $php_reporting = trim(MLAOptions::mla_get_option(MLAOptions::MLA_DEBUG_REPLACE_PHP_REPORTING)); if (!empty($php_reporting)) { @error_reporting(0 + $php_reporting); } /* * This is the earliest effective place to localize values in other plugin components */ MLAOptions::mla_localize_option_definitions_array(); MLASettings::mla_localize_tablist(); MLA_List_Table::mla_localize_default_columns_array(); MLA_Upload_List_Table::mla_localize_default_columns_array(); MLA_Upload_Optional_List_Table::mla_localize_default_columns_array(); MLA_View_List_Table::mla_localize_default_columns_array(); }
/** * Sanitize and expand Optional Upload MIME Type query arguments from request variables * * @since 1.40 * * @param array query parameters from web page, usually found in $_REQUEST * @param int Optional number of rows (default 0) to skip over to reach desired page * @param int Optional number of rows on each page (0 = all rows, default) * * @return array revised arguments suitable for query */ private static function _prepare_optional_upload_items_query($raw_request, $offset = 0, $count = 0) { /* * Go through the $raw_request, take only the arguments that are used in the query and * sanitize or validate them. */ if (!is_array($raw_request)) { /* translators: 1: ERROR tag 2: function name 3: non-array value */ error_log(sprintf(_x('%1$s: %2$s non-array "%3$s"', 'error_log', 'media-library-assistant'), __('ERROR', 'media-library-assistant'), 'MLAMime::_prepare_optional_upload_items_query', var_export($raw_request, true)), 0); return NULL; } $clean_request = array('orderby' => 'slug', 'order' => 'ASC', 's' => ''); foreach ($raw_request as $key => $value) { switch ($key) { case 'orderby': if ('none' == $value) { $clean_request[$key] = $value; } else { $sortable_columns = MLA_Upload_Optional_List_Table::mla_get_sortable_columns(); foreach ($sortable_columns as $sort_key => $sort_value) { if ($value == $sort_value[0]) { $clean_request[$key] = $value; break; } } // foreach } break; case 'order': switch ($value = strtoupper($value)) { case 'ASC': case 'DESC': $clean_request[$key] = $value; break; default: $clean_request[$key] = 'ASC'; } break; /* * ['s'] - Search Media by one or more keywords */ /* * ['s'] - Search Media by one or more keywords */ case 's': $clean_request[$key] = stripslashes(trim($value)); break; default: // ignore anything else in $_REQUEST } // switch $key } // foreach $raw_request /* * Ignore incoming paged value; use offset and count instead */ if ((int) $count > 0) { $clean_request['offset'] = $offset; $clean_request['posts_per_page'] = $count; } return $clean_request; }
/** * This method dictates the table's columns and titles * * @since 1.40 * * @return array Column information: 'slugs'=>'Visible Titles' */ function get_columns() { return $columns = MLA_Upload_Optional_List_Table::mla_manage_columns_filter(); }
/** * Load a plugin text domain * * The "add_action" for this function is in mla-plugin-loader.php, because the "initialize" * function above doesn't run in time. * Defined as public because it's an action. * * @since 1.60 * * @return void */ public static function mla_plugins_loaded_action() { $text_domain = 'media-library-assistant'; $locale = apply_filters('mla_plugin_locale', get_locale(), $text_domain); /* * To override the plugin's translation files for one, some or all strings, * create a sub-directory named 'media-library-assistant' in the WordPress * WP_LANG_DIR (e.g., /wp-content/languages) directory. */ load_textdomain($text_domain, trailingslashit(WP_LANG_DIR) . $text_domain . '/' . $text_domain . '-' . $locale . '.mo'); load_plugin_textdomain($text_domain, false, MLA_PLUGIN_BASENAME . '/languages/'); /* * Now we can localize values in other plugin components */ MLAOptions::mla_localize_option_definitions_array(); MLASettings::mla_localize_tablist(); MLA_List_Table::mla_localize_default_columns_array(); MLA_Upload_List_Table::mla_localize_default_columns_array(); MLA_Upload_Optional_List_Table::mla_localize_default_columns_array(); MLA_View_List_Table::mla_localize_default_columns_array(); }
/** * Compose the Optional File Upload MIME Types tab content for the Settings subpage * * @since 1.40 * * @param string Display templates * * @return array 'message' => status/error messages, 'body' => tab content */ private static function _compose_optional_upload_tab($page_template_array) { /* * Display the Optional Upload MIME Types Table */ $_SERVER['REQUEST_URI'] = add_query_arg(array('mla-optional-uploads-display' => 'true'), remove_query_arg(array('mla_admin_action', 'mla_item_slug', 'mla_item_ID', '_wpnonce', '_wp_http_referer', 'action', 'action2', 'cb_attachment', 'mla-optional-uploads-search'), $_SERVER['REQUEST_URI'])); /* * Suppress display of the hidden columns selection list */ echo " <style type='text/css'>\r\n"; echo " form#adv-settings div.metabox-prefs {\r\n"; echo " display: none;\r\n"; echo " }\r\n"; echo " </style>\r\n"; // Create an instance of our package class $MLAListUploadTable = new MLA_Upload_Optional_List_Table(); // Fetch, prepare, sort, and filter our data $MLAListUploadTable->prepare_items(); $page_content = array('message' => '', 'body' => ''); $page_values = array('form_url' => admin_url('options-general.php') . '?page=mla-settings-menu-upload&mla_tab=upload', '_wpnonce' => wp_nonce_field(MLA::MLA_ADMIN_NONCE_ACTION, MLA::MLA_ADMIN_NONCE_NAME, true, false), 'Known File Extension' => __('Known File Extension/MIME Type Associations', 'media-library-assistant'), 'results' => !empty($_REQUEST['s']) ? '<h2 class="alignleft">' . __('Displaying search results for', 'media-library-assistant') . ': "' . $_REQUEST['s'] . '"</h2>' : '', 'Search Known MIME' => __('Search Known MIME Types', 'media-library-assistant'), 's' => isset($_REQUEST['s']) ? $_REQUEST['s'] : '', 'To search by' => __('To search by extension, use ".", e.g., ".doc"', 'media-library-assistant'), 'Cancel' => __('Cancel', 'media-library-assistant')); $page_content['body'] = MLAData::mla_parse_template($page_template_array['before-optional-uploads-table'], $page_values); // Now we can render the completed list table ob_start(); // $MLAListUploadTable->views(); $MLAListUploadTable->display(); $page_content['body'] .= ob_get_contents(); ob_end_clean(); $page_content['body'] .= MLAData::mla_parse_template($page_template_array['after-optional-uploads-table'], $page_values); return $page_content; }