/** * 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(); }
/** * Save Language settings to the options table * * @since 2.11 * * @uses $_REQUEST * * @return array Message(s) reflecting the results of the operation */ private static function _save_language_settings() { $message_list = ''; foreach (MLA_WPML::$mla_language_option_definitions as $key => $value) { if ('language' == $value['tab']) { $message_list .= MLASettings::mla_update_option_row($key, $value, MLA_WPML::$mla_language_option_definitions); } // language option } // foreach mla_options $page_content = array('message' => __('Language settings saved.', 'media-library-assistant') . "\n", 'body' => ''); /* * Uncomment this for debugging. */ //$page_content['message'] .= $message_list; return $page_content; }
/** * 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(); }
/** * Render (echo) the "Media Library Assistant" subpage in the Settings section * * @since 0.1 * * @return void Echoes HTML markup for the Settings subpage */ public static function mla_render_settings_page() { if (!current_user_can('manage_options')) { echo __('Media Library Assistant', 'media-library-assistant') . ' - ' . __('ERROR', 'media-library-assistant') . "</h2>\r\n"; wp_die(__('You do not have permission to manage plugin settings.', 'media-library-assistant')); } /* * Load template array and initialize page-level values. */ $development_version = MLA::MLA_DEVELOPMENT_VERSION; $development_version = !empty($development_version) ? ' (' . $development_version . ')' : ''; self::$page_template_array = MLAData::mla_load_template('admin-display-settings-page.tpl'); $current_tab_slug = isset($_REQUEST['mla_tab']) ? $_REQUEST['mla_tab'] : 'general'; $current_tab = self::mla_get_options_tablist($current_tab_slug); $page_values = array('Support Our Work' => __('Support Our Work', 'media-library-assistant'), 'Donate' => __('Donate', 'media-library-assistant'), 'version' => 'v' . MLA::CURRENT_MLA_VERSION, 'development' => $development_version, 'messages' => '', 'tablist' => self::_compose_settings_tabs($current_tab_slug), 'tab_content' => '', 'Media Library Assistant' => __('Media Library Assistant', 'media-library-assistant'), 'Settings' => __('Settings', 'media-library-assistant')); /* * Compose tab content */ if ($current_tab) { if (isset($current_tab['render'])) { $handler = $current_tab['render']; $page_content = call_user_func($handler); } else { $page_content = array('message' => __('ERROR', 'media-library-assistant') . ': ' . __('Cannot render content tab', 'media-library-assistant'), 'body' => ''); } } else { $page_content = array('message' => __('ERROR', 'media-library-assistant') . ': ' . __('Unknown content tab', 'media-library-assistant'), 'body' => ''); } if (!empty($page_content['message'])) { if (false !== strpos($page_content['message'], __('ERROR', 'media-library-assistant'))) { $messages_class = 'mla_errors'; } else { $messages_class = 'mla_messages'; } $page_values['messages'] = MLAData::mla_parse_template(self::$page_template_array['messages'], array('messages' => $page_content['message'], 'mla_messages_class' => $messages_class)); } $page_values['tab_content'] = $page_content['body']; echo MLAData::mla_parse_template(self::$page_template_array['page'], $page_values); }
/** * Render (echo) the "Media Library Assistant" subpage in the Settings section * * @since 0.1 * * @return void Echoes HTML markup for the Settings subpage */ public static function mla_render_settings_page() { if (!current_user_can('manage_options')) { echo "Media Library Assistant - Error</h2>\r\n"; wp_die(__('You do not have permission to manage plugin settings.')); } /* * Load template array and initialize page-level values. */ self::$page_template_array = MLAData::mla_load_template(MLA_PLUGIN_PATH . 'tpls/admin-display-settings-page.tpl'); $current_tab = isset($_REQUEST['mla_tab']) ? $_REQUEST['mla_tab'] : 'general'; $page_values = array('settingsURL' => admin_url('options-general.php'), 'version' => 'v' . MLA::CURRENT_MLA_VERSION, 'donateURL' => MLA_PLUGIN_URL . 'images/DonateButton.jpg', 'messages' => '', 'tablist' => self::_compose_settings_tabs($current_tab), 'tab_content' => ''); /* * Compose tab content */ if (array_key_exists($current_tab, self::$mla_tablist)) { if (isset(self::$mla_tablist[$current_tab]['render'])) { $handler = self::$mla_tablist[$current_tab]['render']; $page_content = self::$handler(); } else { $page_content = array('message' => 'ERROR: cannot render content tab', 'body' => ''); } } else { $page_content = array('message' => 'ERROR: unknown content tab', 'body' => ''); } if (!empty($page_content['message'])) { if (false !== strpos($page_content['message'], 'ERROR:')) { $messages_class = 'mla_errors'; } else { $messages_class = 'mla_messages'; } $page_values['messages'] = MLAData::mla_parse_template(self::$page_template_array['messages'], array('messages' => $page_content['message'], 'mla_messages_class' => $messages_class)); } $page_values['tab_content'] = $page_content['body']; echo MLAData::mla_parse_template(self::$page_template_array['page'], $page_values); }