Changeset 1007975
- Timestamp:
- 10/15/2014 03:40:40 PM (11 years ago)
- Location:
- multilingual-press/trunk
- Files:
-
- 17 added
- 4 deleted
- 19 edited
-
css/admin.css (deleted)
-
css/backend.css (added)
-
css/backend.min.css (added)
-
css/frontend.min.css (added)
-
css/language-manager.css (deleted)
-
inc/Multilingual_Press.php (modified) (11 diffs)
-
inc/core/assets (added)
-
inc/core/assets/Mlp_Asset_Loader.php (added)
-
inc/core/assets/Mlp_Asset_Url.php (added)
-
inc/core/assets/Mlp_Asset_Url_Interface.php (added)
-
inc/core/assets/Mlp_Assets.php (added)
-
inc/core/assets/Mlp_Assets_Interface.php (added)
-
inc/core/common/Inpsyde_Property_List.php (modified) (1 diff)
-
inc/core/common/Mlp_Accept_Header_Parser_Interface.php (added)
-
inc/core/common/Mlp_Accept_Header_Validator_Interface.php (added)
-
inc/core/common/Mlp_Helpers.php (modified) (1 diff)
-
inc/core/common/Mlp_Internal_Locations.php (added)
-
inc/core/common/Mlp_Locations_Interface.php (added)
-
inc/core/common/Mlp_Plugin_Properties.php (added)
-
inc/core/common/Mlp_Widget.php (modified) (8 diffs)
-
inc/core/db/Mlp_Table_Names.php (modified) (3 diffs)
-
inc/core/feature.nav-menu.php (modified) (1 diff)
-
inc/core/feature.widget.php (modified) (1 diff)
-
inc/core/general-settings/Mlp_General_Settingspage.php (modified) (2 diffs)
-
inc/core/installation/Mlp_Update_Plugin_Data.php (modified) (4 diffs)
-
inc/core/language-api/Mlp_Language_Api.php (modified) (5 diffs)
-
inc/core/language-api/Mlp_Language_Api_Interface.php (modified) (1 diff)
-
inc/core/language-manager/Mlp_Language_Manager_Controller.php (modified) (2 diffs)
-
inc/core/nav-menu/Mlp_Language_Nav_Menu_Data.php (modified) (9 diffs)
-
inc/core/nav-menu/Mlp_Nav_Menu_Controller.php (modified) (9 diffs)
-
inc/core/nav-menu/Mlp_Nav_Menu_Frontend.php (modified) (1 diff)
-
inc/core/post-translator/Mlp_Translation_Metabox.php (modified) (1 diff)
-
inc/core/types/Mlp_Language.php (modified) (1 diff)
-
js/backend.js (added)
-
js/backend.min.js (added)
-
js/frontend.js (added)
-
js/multilingual_press.js (deleted)
-
js/nav_menu.js (deleted)
-
multilingual-press.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
multilingual-press/trunk/inc/Multilingual_Press.php
r996646 r1007975 151 151 $this->wpdb 152 152 ); 153 $this->plugin_data->assets = new Mlp_Assets( $this->plugin_data->locations ); 154 $this->load_assets(); 153 155 154 156 Mlp_Helpers::$link_table = $this->link_table; … … 182 184 self::$textdomainpath = $this->plugin_data->text_domain_path; 183 185 184 // Show database errors (only for development)185 // $wpdb->show_errors();186 187 186 // Hooks and filters 188 //$this->load_plugin_textdomain();189 187 add_action( 'inpsyde_mlp_loaded', array ( $this, 'load_plugin_textdomain' ), 1 ); 190 188 … … 201 199 add_action( 'admin_enqueue_scripts', array ( $this, 'admin_scripts' ) ); 202 200 203 add_action( 'wp_loaded', array ( $this, 'register_stylesheets' ) );204 205 201 // Cleanup upon blog delete 206 202 add_filter( 'delete_blog', array ( $this, 'delete_blog' ), 10, 2 ); … … 212 208 // Check for errors 213 209 add_filter( 'all_admin_notices', array ( $this, 'check_for_user_errors_admin_notice' ) ); 214 215 // if ( TRUE == $this->check_for_user_errors() ) return;216 210 217 211 add_action( 'wp_loaded', array ( $this, 'late_load' ), 0 ); … … 224 218 225 219 if ( is_admin() ) { 220 226 221 if ( $this->plugin_data->module_manager->has_modules() ) 227 222 $this->load_module_settings_page(); … … 256 251 257 252 /** 258 * @return void259 */260 public function register_stylesheets() {261 wp_register_style( 'mlp-frontend-css', $this->plugin_data->css_url . 'frontend.css' );262 wp_register_style( 'mlp-admin-css', $this->plugin_data->css_url . '/admin.css' );263 }264 265 /**266 253 * Load the localization 267 254 * … … 279 266 280 267 /** 268 * Register assets internally 269 * 270 * @return void 271 */ 272 public function load_assets() { 273 274 /** @type Mlp_Assets $assets */ 275 $assets = $this->plugin_data->assets; 276 $assets->add( 'mlp_backend_js', 'backend.js', array ( 'jquery' ) ); 277 $assets->add( 'mlp_backend_css', 'backend.css' ); 278 $assets->add( 'mlp_frontend_js', 'frontend.js', array ( 'jquery' ) ); 279 $assets->add( 'mlp_frontend_css', 'frontend.css' ); 280 281 add_action( 'init', array ( $assets, 'register' ), 0 ); 282 283 } 284 285 /** 281 286 * Create network settings page. 282 287 * … … 285 290 private function load_module_settings_page() { 286 291 287 $settings = new Mlp_General_Settingspage( $this->plugin_data->module_manager );292 $settings = new Mlp_General_Settingspage( $this->plugin_data->module_manager, $this->plugin_data->assets ); 288 293 add_action( 'plugins_loaded', array ( $settings, 'setup' ), 8 ); 289 294 } … … 296 301 private function load_site_settings_page() { 297 302 298 $settings = new Mlp_General_Settingspage( $this->plugin_data->site_manager );303 $settings = new Mlp_General_Settingspage( $this->plugin_data->site_manager, $this->plugin_data->assets ); 299 304 $settings->setup(); 300 305 add_action( 'plugins_loaded', array ( $settings, 'setup' ), 8 ); … … 318 323 foreach ( $dirs as $dir ) { 319 324 320 $path = $this->plugin_data->plugin_dir_path . " inc/$dir";325 $path = $this->plugin_data->plugin_dir_path . "/inc/$dir"; 321 326 322 327 if ( ! is_readable( $path ) ) … … 360 365 361 366 if ( in_array ( $pagenow, $pages ) ) { 362 wp_enqueue_script( 'mlp-js', $this->plugin_data->js_url . 'multilingual_press.js' );363 wp_localize_script( 'mlp -js', 'mlp_loc', $this->localize_script() );364 wp_enqueue_style( 'mlp-admin-css' );367 //wp_enqueue_script( 'mlp-js', $this->plugin_data->js_url . 'multilingual_press.js' ); 368 wp_localize_script( 'mlp_backend_js', 'mlp_loc', $this->localize_script() ); 369 //wp_enqueue_style( 'mlp-admin-css' ); 365 370 } 366 371 } -
multilingual-press/trunk/inc/core/common/Inpsyde_Property_List.php
r996646 r1007975 239 239 public function has_parent() { 240 240 241 return NULL === $this->parent;241 return NULL !== $this->parent; 242 242 } 243 243 -
multilingual-press/trunk/inc/core/common/Mlp_Helpers.php
r999339 r1007975 104 104 105 105 // no blogs with a link to other blogs 106 if ( '-1' === $language_data[ 'lang' ] )106 if ( empty ( $language_data[ 'lang' ] ) || '-1' === $language_data[ 'lang' ] ) 107 107 continue; 108 108 -
multilingual-press/trunk/inc/core/common/Mlp_Widget.php
r999339 r1007975 4 4 * 5 5 * @author Inpsyde GmbH, toscho 6 * @version 2014. 09.296 * @version 2014.10.10 7 7 * @license GPL 8 8 */ … … 13 13 */ 14 14 protected static $handle = 'mlp_widget'; 15 16 /** 17 * @type Mlp_Assets_Interface 18 */ 19 private static $assets; 15 20 16 21 /** … … 24 29 ); 25 30 26 add_ filter( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );31 add_action( 'template_redirect', array ( $this, 'require_style' ) ); 27 32 28 33 parent::__construct( 'Mlp_Widget', __( 'Language Switcher', 'multilingualpress' ), $widget_ops ); … … 32 37 * Load frontend CSS if the widget is active 33 38 * 34 * @return void 35 */ 36 public function enqueue_styles() { 37 38 if ( is_active_widget( FALSE, FALSE, self::$handle ) 39 //or 'off' !== $this->get_module_state( array( 'slug' => 'class-Multilingual_Press_Quicklink' ) ) 39 * @return bool 40 */ 41 public function require_style() { 42 43 if ( ! is_active_widget( FALSE, FALSE, self::$handle ) ) 44 return FALSE; 45 46 $theme_support = get_theme_support( 'multilingualpress' ); 47 48 if ( $theme_support 49 && ! empty ( $theme_support[0][ 'language_switcher_widget_style' ] ) 40 50 ) 41 wp_enqueue_style( 'mlp-frontend-css' ); 51 return FALSE; 52 53 self::$assets->provide( 'mlp_frontend_css' ); 54 55 return TRUE; 42 56 } 43 57 … … 163 177 * Frontend display 164 178 * 179 * When a widget is restored from trash, the instance might be incomplete. 180 * Hence the preparations. 181 * 165 182 * @param array $args 166 183 * @param array $instance | widget settings … … 169 186 public function widget( $args, $instance ) { 170 187 188 $link_type = 'text'; 189 190 if ( ! empty ( $instance[ 'widget_link_type' ] ) ) 191 $link_type = $instance[ 'widget_link_type' ]; 192 193 $show_current = TRUE; 194 195 if ( isset ( $instance[ 'widget_show_current_blog' ] ) ) 196 $show_current = (int) $instance[ 'widget_show_current_blog' ] === 1; 197 171 198 $output = mlp_show_linked_elements( 172 199 array ( 173 'link_text' => $ instance[ 'widget_link_type' ],174 'show_current_blog' => $ instance[ 'widget_show_current_blog' ] == 1,200 'link_text' => $link_type, 201 'show_current_blog' => $show_current, 175 202 'echo' => FALSE 176 203 ) … … 180 207 return; 181 208 182 echo $args['before_widget']; 183 184 // Display Title (optional) 185 if ( $instance[ 'widget_title' ] ) { 186 echo $args['before_title'] 187 . apply_filters( 'widget_title', $instance[ 'widget_title' ] ) 188 . $args['after_title']; 189 } 190 191 echo $output . $args['after_widget']; 209 $title = ''; 210 211 if ( isset ( $instance[ 'widget_title' ] ) ) 212 $title = $instance[ 'widget_title' ]; 213 214 $title = apply_filters( 'widget_title', $title ); 215 216 echo $args[ 'before_widget' ]; 217 218 if ( ! empty ( $instance[ 'widget_title' ] ) ) 219 echo $args[ 'before_title' ] . $title . $args[ 'after_title' ]; 220 221 echo $output . $args[ 'after_widget' ]; 192 222 } 193 223 … … 198 228 */ 199 229 public static function widget_register() { 230 200 231 register_widget( __CLASS__ ); 201 232 } 233 234 /** 235 * @param Mlp_Assets_Interface $assets 236 * @return void 237 */ 238 public static function insert_asset_instance( 239 Mlp_Assets_Interface $assets 240 ) { 241 242 self::$assets = $assets; 243 } 202 244 } -
multilingual-press/trunk/inc/core/db/Mlp_Table_Names.php
r996646 r1007975 61 61 62 62 return $tables; 63 64 63 } 65 64 … … 93 92 94 93 /** 95 * Get core table only.94 * Get core tables only. 96 95 * 97 96 * @param bool $do_prefix Should the table names be prefixed? … … 100 99 public function get_core_site_tables( $do_prefix = TRUE ) { 101 100 102 $cache_key = "site-core-{$this->site_id}"; 101 $cache_key = "site-core-{$this->site_id}-" 102 . ( $do_prefix ? 1 : 0 ); 103 103 $cache = wp_cache_get( $cache_key, $this->cache_group ); 104 104 -
multilingual-press/trunk/inc/core/feature.nav-menu.php
r996646 r1007975 8 8 function mlp_nav_menu_init( Inpsyde_Property_List_Interface $data ) { 9 9 10 $controller = new Mlp_Nav_Menu_Controller( $data->language_api ); 10 $controller = new Mlp_Nav_Menu_Controller( 11 $data->language_api, 12 $data->assets 13 ); 11 14 12 15 if ( is_admin() ) -
multilingual-press/trunk/inc/core/feature.widget.php
r996646 r1007975 1 1 <?php # -*- coding: utf-8 -*- 2 2 3 add_action( 'inpsyde_mlp_init', 'mlp_widget_setup' ); 4 3 5 add_action( 'widgets_init', array ( 'Mlp_Widget', 'widget_register' ) ); 6 7 /** 8 * @param Inpsyde_Property_List_Interface $plugin_data 9 * @return void 10 */ 11 function mlp_widget_setup( Inpsyde_Property_List_Interface $plugin_data ) { 12 Mlp_Widget::insert_asset_instance( $plugin_data->assets ); 13 } -
multilingual-press/trunk/inc/core/general-settings/Mlp_General_Settingspage.php
r996646 r1007975 21 21 22 22 /** 23 * @type Mlp_Assets_Interface 24 */ 25 private $assets; 26 27 /** 23 28 * Constructor 24 29 * 25 30 * @param Mlp_Module_Manager_Interface $modules 31 * @param Mlp_Assets_Interface $assets 26 32 */ 27 public function __construct( Mlp_Module_Manager_Interface $modules ) {33 public function __construct( Mlp_Module_Manager_Interface $modules, Mlp_Assets_Interface $assets ) { 28 34 $this->modules = $modules; 35 $this->assets = $assets; 29 36 } 30 37 … … 63 70 ); 64 71 65 add_filter( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); 66 } 67 68 /** 69 * Load the scripts for the options page 70 * 71 * @param string $hook | current page identifier 72 * @return void 73 */ 74 public function admin_scripts( $hook = NULL ) { 75 76 if ( $this->page_hook === $hook ) { 77 wp_enqueue_script( 'dashboard' ); 78 wp_enqueue_style( 'dashboard' ); 79 wp_enqueue_style( 'mlp-admin-css' ); 80 } 72 $this->assets->provide( array ( 'mlp_backend_js', 'mlp_backend_css' ) ); 81 73 } 82 74 -
multilingual-press/trunk/inc/core/installation/Mlp_Update_Plugin_Data.php
r999339 r1007975 80 80 if ( Mlp_Version_Number_Interface::FALLBACK_VERSION === $this->last_version ) 81 81 $this->update_plugin_data( 1 ); 82 83 $this->update_plugin_data( $this->last_version );82 else 83 $this->update_plugin_data( $this->last_version ); 84 84 } 85 85 … … 125 125 126 126 if ( ! empty ( $linked ) ) 127 $inserted += $relations->set_relation( $site[ 'blog_id'], $linked );128 129 delete_blog_option( $site[ 'blog_id'], $option_name );127 $inserted += $relations->set_relation( $site[ 'blog_id' ], $linked ); 128 129 delete_blog_option( $site[ 'blog_id' ], $option_name ); 130 130 } 131 131 } … … 195 195 * Install plugin tables. 196 196 * 197 * @needs-refactoring 198 * @return void 197 * @return bool 199 198 */ 200 199 public function install_plugin() { … … 204 203 $installer->install( new Mlp_Content_Relations_Schema( $this->wpdb ) ); 205 204 $installer->install( new Mlp_Site_Relations_Schema( $this->wpdb ) ); 205 206 return update_site_option( 'mlp_version', $this->plugin_data->version ); 206 207 } 207 208 } -
multilingual-press/trunk/inc/core/language-api/Mlp_Language_Api.php
r999339 r1007975 256 256 ); 257 257 258 if ( ! isset ( $data[ 'http_name' ] ) ) { 259 if ( isset ( $data[ 'lang' ] ) ) 260 $data[ 'http_name' ] = $data[ 'lang' ]; 261 else 262 $data[ 'http_name' ] = ''; 263 } 264 258 265 $icon = $this->get_flag_by_language( $data[ 'http_name' ], $site_id ); 259 266 … … 287 294 $file_name = $sub . '.gif'; 288 295 289 if ( is_readable( $this->data->flag_path . $file_name) )296 if ( is_readable( "{$this->data->flag_path}/$file_name" ) ) 290 297 return new Mlp_Url( $this->data->flag_url . $file_name ); 291 298 … … 361 368 return array(); 362 369 363 $tags = wp_list_pluck( $languages, 'lang' ); 364 365 foreach ( $tags as $site => $tag ) 366 $tags[ $site ] = str_replace('_', '-', $tag ); 370 $tags = array(); 371 $add_like = array(); 372 373 foreach ( $languages as $site_id => $data ) { 374 if ( ! empty ( $data[ 'lang' ] ) ) 375 $tags[ $site_id ] = str_replace('_', '-', $data[ 'lang' ] ); 376 elseif ( ! empty ( $data[ 'text' ] ) && preg_match( '~[a-zA-Z-]+~', $data[ 'text' ] ) ) 377 $tags[ $site_id ] = str_replace('_', '-', $data[ 'text' ] ); 378 379 // a site might have just 'EN' as text and no other values 380 if ( FALSE === strpos( $tags[ $site_id ], '-' ) ) { 381 $tags[ $site_id ] = strtolower( $tags[ $site_id ] ); 382 $add_like[ $site_id ] = $tags[ $site_id ]; 383 } 384 } 367 385 368 386 $values = array_values( $tags ); … … 370 388 371 389 $sql = " 372 SELECT `english_name`, `native_name`, `custom_name`, `is_rtl`, `http_name`, `priority`, `wp_locale` 390 SELECT `english_name`, `native_name`, `custom_name`, `is_rtl`, `http_name`, `priority`, `wp_locale`, `iso_639_1` 373 391 FROM $this->table_name 374 WHERE `http_name` IN( $values );"; 392 WHERE `http_name` IN( $values )"; 393 394 if ( ! empty ( $add_like ) ) { 395 $sql .= " OR `iso_639_1` IN ('" . join("','", array_values( $add_like )) . "')"; 396 } 375 397 376 398 $results = $this->wpdb->get_results( $sql, ARRAY_A ); … … 380 402 foreach ( $results as $arr ) { 381 403 if ( in_array( $lang, $arr ) ) { 404 $languages[ $site ] += $arr; 405 } 406 elseif ( isset ( $add_like[ $site ] ) 407 && $arr[ 'iso_639_1' ] === $add_like[ $site ] 408 ) { 382 409 $languages[ $site ] += $arr; 383 410 } -
multilingual-press/trunk/inc/core/language-api/Mlp_Language_Api_Interface.php
r996646 r1007975 44 44 * - 'search_term' if you want to translate a search 45 45 * - 'post_type' for post type archives 46 * - 'include_base' bool. Include the base site in returned list 46 47 * 47 48 * @param array $args Optional. If left out, some magic happens. -
multilingual-press/trunk/inc/core/language-manager/Mlp_Language_Manager_Controller.php
r996646 r1007975 116 116 ); 117 117 118 // for JavaScript use "admin_print_scripts-$id" 119 add_action( "admin_print_styles-$page_id", array ( $this, 'enqueue_style' ) ); 118 add_action( "load-$page_id", array ( $this, 'enqueue_style' ) ); 120 119 } 121 120 … … 124 123 */ 125 124 public function enqueue_style() { 126 wp_enqueue_style( 127 'language_manager', 128 $this->plugin_data->css_url . 'language-manager.css' 129 ); 125 126 $this->plugin_data->assets->provide( 'mlp_backend_css' ); 130 127 } 131 128 -
multilingual-press/trunk/inc/core/nav-menu/Mlp_Language_Nav_Menu_Data.php
r996646 r1007975 3 3 * Data read and write for backend nav menu management. 4 4 * 5 * @version 2014. 07.155 * @version 2014.10.10 6 6 * @author Inpsyde GmbH, toscho 7 7 * @license GPL … … 11 11 12 12 /** 13 * @ varstring13 * @type string 14 14 */ 15 15 private $meta_key; … … 18 18 * Button id. 19 19 * 20 * @ varstring20 * @type string 21 21 */ 22 22 private $button_id = 'mlp_language'; 23 23 24 24 /** 25 * @ varstring25 * @type string 26 26 */ 27 27 private $handle; 28 28 29 29 /** 30 * @ varInpsyde_Nonce_Validator_Interface30 * @type Inpsyde_Nonce_Validator_Interface 31 31 */ 32 32 private $nonce; 33 33 34 34 /** 35 * @var string 36 */ 37 private $js_url; 38 39 /** 35 * @type Mlp_Assets_Interface 36 */ 37 private $assets; 38 39 /** 40 * Constructor 41 * 40 42 * @param string $handle 41 43 * @param string $meta_key 42 44 * @param Inpsyde_Nonce_Validator_Interface $nonce 43 * @param string $js_url 44 */ 45 function __construct( 46 $handle, 45 * @param Mlp_Assets_Interface $assets 46 */ 47 function __construct( $handle, 47 48 $meta_key, 48 49 Inpsyde_Nonce_Validator_Interface $nonce, 49 $js_url 50 Mlp_Assets_Interface $assets 50 51 ) { 51 52 $this->handle = $handle; 52 53 $this->meta_key = $meta_key; 53 54 $this->nonce = $nonce; 54 $this-> js_url = $js_url . "nav_menu.js";55 $this->assets = $assets; 55 56 } 56 57 … … 92 93 public function register_script() { 93 94 94 wp_register_script( $this->handle, $this->js_url, array( 'jquery' ), 1, TRUE);95 $this->assets->provide( array ( 'mlp_backend_js', 'mlp_backend_css' ) ); 95 96 } 96 97 … … 103 104 if ( 'nav-menus.php' !== $hook ) 104 105 return; 105 106 wp_enqueue_script( $this->handle );107 106 108 107 $data = array ( … … 116 115 $data[ 'nonce_name' ] = $this->nonce->get_name(); 117 116 118 wp_localize_script( $this->handle, $this->handle, $data );117 wp_localize_script( 'mlp_backend_js', $this->handle, $data ); 119 118 } 120 119 … … 183 182 */ 184 183 private function is_valid_blog_id( Array $titles, $blog_id ) { 184 185 185 return isset ( $titles[ $blog_id ] ) && blog_exists( $blog_id ); 186 186 } … … 203 203 ); 204 204 205 $item_id = wp_update_nav_menu_item( $_POST['menu'], 0, $menu_item_data ); 206 205 $item_id = wp_update_nav_menu_item( 206 $_POST[ 'menu' ], 207 0, 208 $menu_item_data 209 ); 207 210 $menu_item = get_post( $item_id ); 208 211 … … 220 223 221 224 // don't show "(pending)" in ajax-added items 222 $menu_item->post_type = 'nav_menu_item';223 $menu_item->url = get_home_url( $blog_id, '/' );224 $menu_item->object = 'mlp_language';225 $menu_item->xfn = 'alternate';226 $menu_item = wp_setup_nav_menu_item( $menu_item );227 $menu_item->label = $menu_item->title;225 $menu_item->post_type = 'nav_menu_item'; 226 $menu_item->url = get_home_url( $blog_id, '/' ); 227 $menu_item->object = 'mlp_language'; 228 $menu_item->xfn = 'alternate'; 229 $menu_item = wp_setup_nav_menu_item( $menu_item ); 230 $menu_item->label = $menu_item->title; 228 231 // Replace the "Custom" in the management screen 229 232 $menu_item->type_label = esc_html__( 'Language', 'multilingualpress' ); 230 233 $menu_item->classes[ ] = "blog-id-$blog_id"; 231 234 $menu_item->classes[ ] = "mlp-language-nav-item"; 232 $menu_item->url = get_home_url( $blog_id, '/' );235 $menu_item->url = get_home_url( $blog_id, '/' ); 233 236 234 237 update_post_meta( $menu_item->ID, $this->meta_key, $blog_id ); 235 update_post_meta( $menu_item->ID, '_menu_item_url', esc_url_raw(get_home_url( $blog_id, '/' )) ); 238 $url = esc_url_raw( get_home_url( $blog_id, '/' ) ); 239 update_post_meta( $menu_item->ID, '_menu_item_url', $url ); 236 240 237 241 return $menu_item; -
multilingual-press/trunk/inc/core/nav-menu/Mlp_Nav_Menu_Controller.php
r996646 r1007975 3 3 * Front controller for language menu items. 4 4 * 5 * @version 2014. 05.135 * @version 2014.10.10 6 6 * @author Inpsyde GmbH, toscho 7 7 * @license GPL … … 12 12 * Basic identifier for all sort of operations. 13 13 * 14 * @ varstring14 * @type string 15 15 */ 16 16 private $handle = 'mlp_nav_menu'; … … 19 19 * Post meta key for nav items. 20 20 * 21 * @ varstring21 * @type string 22 22 */ 23 23 private $meta_key = '_blog_id'; … … 33 33 * Backend view. 34 34 * 35 * @ varMlp_Simple_Nav_Menu_Selectors35 * @type Mlp_Simple_Nav_Menu_Selectors 36 36 */ 37 37 private $view; 38 38 39 39 /** 40 * 41 * 42 * @type 40 * @type Mlp_Language_Api_Interface 43 41 */ 44 42 private $language_api; 45 43 46 44 /** 45 * @type Mlp_Assets_Interface 46 */ 47 private $assets; 48 49 /** 50 * Constructor 51 * 47 52 * @param Mlp_Language_Api_Interface $language_api 53 * @param Mlp_Assets_Interface $assets 48 54 */ 49 public function __construct( Mlp_Language_Api_Interface $language_api ) { 55 public function __construct( 56 Mlp_Language_Api_Interface $language_api, 57 Mlp_Assets_Interface $assets 58 ) { 50 59 51 60 $this->language_api = $language_api; 61 $this->assets = $assets; 52 62 } 53 63 … … 60 70 public function frontend_setup() { 61 71 62 add_filter( 63 'wp_nav_menu_objects', 64 array ( 65 new Mlp_Nav_Menu_Frontend( $this->meta_key, $this->language_api ), 66 'filter_items' 67 ) 72 $frontend = new Mlp_Nav_Menu_Frontend( 73 $this->meta_key, 74 $this->language_api 68 75 ); 76 77 add_filter( 'wp_nav_menu_objects', array ( $frontend, 'filter_items' ) ); 69 78 } 70 79 … … 90 99 public function add_meta_box() { 91 100 101 $title = esc_html__( 'Languages', 'multilingualpress' ); 102 92 103 add_meta_box( 93 104 $this->handle, 94 __( 'Languages', 'multilingualpress' ),105 $title, 95 106 array ( $this->view, 'show_available_languages' ), 96 107 'nav-menus', … … 104 115 * 105 116 * @wp-hook inpsyde_mlp_loaded 106 * @param string $js_url107 117 * @return void 108 118 */ 109 private function create_instances( $js_url) {119 private function create_instances() { 110 120 111 $nonce = new Inpsyde_Nonce_Validator(121 $nonce = new Inpsyde_Nonce_Validator( 112 122 $this->handle 113 123 ); … … 116 126 $this->meta_key, 117 127 $nonce, 118 $ js_url128 $this->assets 119 129 ); 120 130 $this->view = new Mlp_Simple_Nav_Menu_Selectors( … … 133 143 array ( $this->data, 'register_script' ) 134 144 ); 145 135 146 add_action( 136 147 'admin_enqueue_scripts', 137 148 array ( $this->data, 'load_script' ) 138 149 ); 150 139 151 add_action( 140 152 "wp_ajax_$this->handle", 141 153 array ( $this->view, 'show_selected_languages' ) 142 154 ); 155 143 156 add_action( 144 157 'admin_init', -
multilingual-press/trunk/inc/core/nav-menu/Mlp_Nav_Menu_Frontend.php
r996646 r1007975 42 42 public function filter_items( Array $items ) { 43 43 44 $translations = $this->language_api->get_translations( 45 array ( 'strict' => FALSE ) 44 $args = array ( 45 'strict' => FALSE, 46 'include_base' => TRUE 46 47 ); 48 $translations = $this->language_api->get_translations( $args ); 47 49 48 50 if ( empty ( $translations ) ) -
multilingual-press/trunk/inc/core/post-translator/Mlp_Translation_Metabox.php
r996646 r1007975 132 132 $this->register_metabox_per_language( $blog_id, $post ); 133 133 } 134 135 $this->plugin_data->assets->provide( 'mlp_backend_css' ); 136 $this->plugin_data->assets->provide( 'mlp_backend_js' ); 134 137 } 135 138 -
multilingual-press/trunk/inc/core/types/Mlp_Language.php
r996646 r1007975 64 64 65 65 if ( $name === 'language_long' ) 66 return $this->names[ 'http_name' ];66 return $this->names[ 'http_name' ]; 67 67 68 68 // $name is empty or invalid, so ... -
multilingual-press/trunk/multilingual-press.php
r999339 r1007975 6 6 * Author: Inpsyde GmbH 7 7 * Author URI: http://inpsyde.com 8 * Version: 2.1. 18 * Version: 2.1.2 9 9 * Text Domain: multilingualpress 10 10 * Domain Path: /languages … … 26 26 global $wp_version, $wpdb, $pagenow; 27 27 28 $path = plugin_dir_path( __FILE__ ); 28 $plugin_path = plugin_dir_path( __FILE__ ); 29 $plugin_url = plugins_url( '/', __FILE__ ); 29 30 30 31 if ( ! class_exists( 'Mlp_Load_Controller' ) ) 31 require $p ath . 'inc/autoload/Mlp_Load_Controller.php';32 require $plugin_path . 'inc/autoload/Mlp_Load_Controller.php'; 32 33 33 $loader = new Mlp_Load_Controller( $path . 'inc' ); 34 $data = new Inpsyde_Property_List; 34 $loader = new Mlp_Load_Controller( $plugin_path . 'inc' ); 35 $data = new Mlp_Plugin_Properties; 36 $data->loader = $loader->get_loader(); 37 $data->locations = new Mlp_Internal_Locations; 35 38 36 $data->loader = $loader->get_loader(); 37 $data->plugin_dir_path = $path; 39 $data->locations->add_dir( $plugin_path, $plugin_url, 'plugin' ); 40 41 foreach ( array ( 'css', 'js', 'flags', 'images' ) as $type ) { 42 $data->locations->add_dir( 43 $plugin_path . $type, 44 $plugin_url . $type, 45 $type 46 ); 47 } 38 48 $data->plugin_file_path = __FILE__; 39 49 $data->plugin_base_name = plugin_basename( __FILE__ ); 40 $data->plugin_url = plugins_url( '/', __FILE__ );41 $data->css_url = "{$data->plugin_url}css/";42 $data->js_url = "{$data->plugin_url}js/";43 $data->image_url = "{$data->plugin_url}images/";44 $data->flag_url = "{$data->plugin_url}flags/";45 $data->flag_path = "{$data->plugin_dir_path}flags/";46 50 47 51 $headers = get_file_data( -
multilingual-press/trunk/readme.txt
r999645 r1007975 100 100 101 101 == Changelog == 102 103 = 2.1.2 Edith Fellowes = 104 105 - Combine all scripts and stylesheets, separated for frontend and backend. 106 - Minify scripts and stylesheets when `SCRIPT_DEBUG` and `MULTILINGUALPRESS_DEBUG` are not set. 107 - Make the icon/flag for the current site available in nav menus. 108 - Sites with custom name are now returned in `Mlp_Language_Api::get_translations()`. 109 - Better updates: Make sure that site relations are not lost and languages are not duplicated. 102 110 103 111 = 2.1.1 =
Note: See TracChangeset
for help on using the changeset viewer.