/** * Register and enqueue admin-specific JavaScript. * * @since 1.0 * * @param string $hook_suffix The current admin page. */ public function enqueue_admin_scripts($hook_suffix) { $screen = get_current_screen(); if (!in_array($hook_suffix, $this->screen_hooks) && !in_array($screen->id, $this->screen_hooks)) { return; } $scripts = $this->admin_scripts($hook_suffix); foreach ($scripts as $slug => $script) { wp_enqueue_script(WPMOLY_SLUG . '-' . $slug, WPMOLY_URL . $script[0], $script[1], WPMOLY_VERSION, $script[2]); } wp_localize_script(WPMOLY_SLUG . '-admin', 'wpmoly_lang', WPMOLY_L10n::localize_script()); }
/** * Generate a list of all countries used in movies * * @since 2.0 * * @param boolean $count Shall we add count? * * @return array */ public static function get_used_countries($count = false) { $used_countries = array(); if (true !== $count) { $count = false; } $countries = self::get_used_meta('production_countries', $count); foreach ($countries as $i => $country) { $_country = WPMOLY_L10n::get_country_standard_name($country['name']); if ($_country != $country['name']) { if (!$count) { $used_countries[$country['name']] = __($_country, 'wpmovielibrary-iso'); } else { $used_countries[$country['name']] = sprintf('%s (%s)', __($_country, 'wpmovielibrary-iso'), sprintf(_n('%d movie', '%d movies', $country['count'], 'wpmovielibrary'), $country['count'])); } } } return $used_countries; }
/** * Format a Movie's countries for display * * @since 2.0 * * @param string $data field value * * @return string Formatted output */ public static function format_movie_production_countries($data) { if (is_null($data) || '' == $data) { return $data; } if ('1' == wpmoly_o('translate-countries')) { $format = wpmoly_o('countries-format', array()); } else { $format = array('flag', 'original'); } $data = explode(',', $data); foreach ($data as $i => $country) { $country = trim($country); $value = $country; $_value = array(); foreach ($format as $c => $f) { switch ($f) { case 'flag': $country = WPMOLY_L10n::get_country_standard_name($country); $code = WPMOLY_L10n::get_country_code($country); $text = self::movie_country_flag($code, $country); break; case 'original': $text = $country; break; case 'translated': $country = WPMOLY_L10n::get_country_standard_name($country); $country = __($country, 'wpmovielibrary-iso'); $text = $country; break; case 'ptranslated': $country = __($country, 'wpmovielibrary-iso'); $text = sprintf('(%s)', $country); break; case 'poriginal': $country = WPMOLY_L10n::get_country_standard_name($country); $text = sprintf('(%s)', $country); break; default: $text = ''; break; } if ('flag' != $f && '' != $text) { $text = apply_filters('wpmoly_movie_meta_link', array('key' => 'production_countries', 'value' => $value, 'type' => 'meta', 'text' => $text, 'title' => sprintf(__('More movies from country %s', 'wpmovielibrary'), $text))); } $_value[] = $text; } $data[$i] = implode(' ', $_value); } $data = implode(', ', $data); $output = self::format_movie_field($data); return $output; }
private static function filter_value($value) { if ('1' == wpmoly_o('rewrite-enable')) { $value = WPMOLY_L10n::untranslate_rewrite($value); } else { $value = WPMOLY_L10n::translate_rewrite($value); } return $value; }
/** * Parse grid sorting parameters * * @since 2.1.1 * * @param array $args Query parameters * * @return array Parsed parameters */ public static function parse_query_vars($vars) { $translate = '1' == wpmoly_o('rewrite-enable'); $defaults = array('letter', 'paged', 'columns', 'rows', 'order', 'meta', 'detail', 'value', 'view'); $params = array(); foreach ($defaults as $default) { if (isset($vars[$default])) { $var = $vars[$default]; if ($translate || in_array($default, array('meta', 'detail'))) { $var = WPMOLY_L10n::untranslate_rewrite($var); } $params[$default] = $var; } } // I can haz sortingz! if (isset($vars['sorting']) && '' != $vars['sorting']) { $sorting = '/' . $vars['sorting']; $regex = array('letter' => '(\\/([0-9A-Za-z]{1}))\\/', 'number' => '(([0-9]{1,})\\:([0-9]{1,})|([0-9]{1,}))\\/?', 'order' => '(asc|desc|ASC|DESC)\\/?', 'orderby' => '(title|year|date|localdate|rating)\\/?', 'paged' => '(page\\/([0-9]{1,}))\\/?'); // Has letter? $preg = preg_match("/{$regex['letter']}/", $sorting, $matches); if ($preg && isset($matches[2]) && '' != $matches[2]) { $params['letter'] = $matches[2]; } // Has number/columns? $preg = preg_match("/{$regex['number']}/", $sorting, $matches); if ($preg && (isset($matches[2]) && '' != $matches[2]) && (isset($matches[3]) && '' != $matches[3])) { $params['columns'] = $matches[2]; $params['rows'] = $matches[3]; } // Has sorting? $preg = preg_match("/{$regex['order']}/", $sorting, $matches); if ($preg && isset($matches[1]) && '' != $matches[1]) { $params['order'] = strtoupper($matches[1]); } $preg = preg_match("/{$regex['orderby']}/", $sorting, $matches); if ($preg && isset($matches[1]) && '' != $matches[1]) { $params['orderby'] = $matches[1]; } // Has pagination? $preg = preg_match("/{$regex['paged']}/", $sorting, $matches); if ($preg) { $params['paged'] = $matches[2]; } } return $params; }
/** * Initialize the plugin by setting localization and loading public scripts * and styles. * * @since 1.0 */ protected function __construct() { $this->register_hook_callbacks(); $this->modules = array('WPMOLY_Settings' => WPMOLY_Settings::get_instance(), 'WPMOLY_Cache' => WPMOLY_Cache::get_instance(), 'WPMOLY_L10n' => WPMOLY_L10n::get_instance(), 'WPMOLY_Utils' => WPMOLY_Utils::get_instance(), 'WPMOLY_Movies' => WPMOLY_Movies::get_instance(), 'WPMOLY_Headbox' => WPMOLY_Headbox::get_instance(), 'WPMOLY_Search' => WPMOLY_Search::get_instance(), 'WPMOLY_Collections' => WPMOLY_Collections::get_instance(), 'WPMOLY_Genres' => WPMOLY_Genres::get_instance(), 'WPMOLY_Actors' => WPMOLY_Actors::get_instance(), 'WPMOLY_Archives' => WPMOLY_Archives::get_instance(), 'WPMOLY_Shortcodes' => WPMOLY_Shortcodes::get_instance(), 'WPMOLY_Legacy' => WPMOLY_Legacy::get_instance()); $this->widgets = array('WPMOLY_Statistics_Widget', 'WPMOLY_Taxonomies_Widget', 'WPMOLY_Details_Widget', 'WPMOLY_Movies_Widget'); }