Plugin Directory

Changeset 1007975


Ignore:
Timestamp:
10/15/2014 03:40:40 PM (11 years ago)
Author:
toscho
Message:

Preparations for version 2.1.2

Location:
multilingual-press/trunk
Files:
17 added
4 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • multilingual-press/trunk/inc/Multilingual_Press.php

    r996646 r1007975  
    151151            $this->wpdb
    152152        );
     153        $this->plugin_data->assets = new Mlp_Assets( $this->plugin_data->locations );
     154        $this->load_assets();
    153155
    154156        Mlp_Helpers::$link_table           = $this->link_table;
     
    182184        self::$textdomainpath = $this->plugin_data->text_domain_path;
    183185
    184         // Show database errors (only for development)
    185         // $wpdb->show_errors();
    186 
    187186        // Hooks and filters
    188         //$this->load_plugin_textdomain();
    189187        add_action( 'inpsyde_mlp_loaded', array ( $this, 'load_plugin_textdomain' ), 1 );
    190188
     
    201199        add_action( 'admin_enqueue_scripts', array ( $this, 'admin_scripts' ) );
    202200
    203         add_action( 'wp_loaded', array ( $this, 'register_stylesheets' ) );
    204 
    205201        // Cleanup upon blog delete
    206202        add_filter( 'delete_blog', array ( $this, 'delete_blog' ), 10, 2 );
     
    212208        // Check for errors
    213209        add_filter( 'all_admin_notices', array ( $this, 'check_for_user_errors_admin_notice' ) );
    214 
    215         // if ( TRUE == $this->check_for_user_errors() )            return;
    216210
    217211        add_action( 'wp_loaded', array ( $this, 'late_load' ), 0 );
     
    224218
    225219        if ( is_admin() ) {
     220
    226221            if ( $this->plugin_data->module_manager->has_modules() )
    227222                $this->load_module_settings_page();
     
    256251
    257252    /**
    258      * @return void
    259      */
    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     /**
    266253     * Load the localization
    267254     *
     
    279266
    280267    /**
     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    /**
    281286     * Create network settings page.
    282287     *
     
    285290    private function load_module_settings_page() {
    286291
    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 );
    288293        add_action( 'plugins_loaded', array ( $settings, 'setup' ), 8 );
    289294    }
     
    296301    private function load_site_settings_page() {
    297302
    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 );
    299304        $settings->setup();
    300305        add_action( 'plugins_loaded', array ( $settings, 'setup' ), 8 );
     
    318323        foreach ( $dirs as $dir ) {
    319324
    320             $path = $this->plugin_data->plugin_dir_path . "inc/$dir";
     325            $path = $this->plugin_data->plugin_dir_path . "/inc/$dir";
    321326
    322327            if ( ! is_readable( $path ) )
     
    360365
    361366        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' );
    365370        }
    366371    }
  • multilingual-press/trunk/inc/core/common/Inpsyde_Property_List.php

    r996646 r1007975  
    239239    public function has_parent() {
    240240
    241         return NULL === $this->parent;
     241        return NULL !== $this->parent;
    242242    }
    243243
  • multilingual-press/trunk/inc/core/common/Mlp_Helpers.php

    r999339 r1007975  
    104104
    105105            // no blogs with a link to other blogs
    106             if ( '-1' === $language_data[ 'lang' ] )
     106            if ( empty ( $language_data[ 'lang' ] ) || '-1' === $language_data[ 'lang' ] )
    107107                continue;
    108108
  • multilingual-press/trunk/inc/core/common/Mlp_Widget.php

    r999339 r1007975  
    44 *
    55 * @author  Inpsyde GmbH, toscho
    6  * @version 2014.09.29
     6 * @version 2014.10.10
    77 * @license GPL
    88 */
     
    1313     */
    1414    protected static $handle = 'mlp_widget';
     15
     16    /**
     17     * @type Mlp_Assets_Interface
     18     */
     19    private static $assets;
    1520
    1621    /**
     
    2429        );
    2530
    26         add_filter( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
     31        add_action( 'template_redirect', array ( $this, 'require_style' ) );
    2732
    2833        parent::__construct( 'Mlp_Widget', __( 'Language Switcher', 'multilingualpress' ), $widget_ops );
     
    3237     * Load frontend CSS if the widget is active
    3338     *
    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' ] )
    4050        )
    41             wp_enqueue_style( 'mlp-frontend-css' );
     51            return FALSE;
     52
     53        self::$assets->provide( 'mlp_frontend_css' );
     54
     55        return TRUE;
    4256    }
    4357
     
    163177     * Frontend display
    164178     *
     179     * When a widget is restored from trash, the instance might be incomplete.
     180     * Hence the preparations.
     181     *
    165182     * @param   array $args
    166183     * @param   array $instance | widget settings
     
    169186    public function widget( $args, $instance ) {
    170187
     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
    171198        $output = mlp_show_linked_elements(
    172199            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,
    175202                'echo'              => FALSE
    176203            )
     
    180207            return;
    181208
    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' ];
    192222    }
    193223
     
    198228     */
    199229    public static function widget_register() {
     230
    200231        register_widget( __CLASS__ );
    201232    }
     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    }
    202244}
  • multilingual-press/trunk/inc/core/db/Mlp_Table_Names.php

    r996646 r1007975  
    6161
    6262        return $tables;
    63 
    6463    }
    6564
     
    9392
    9493    /**
    95      * Get core table only.
     94     * Get core tables only.
    9695     *
    9796     * @param  bool $do_prefix Should the table names be prefixed?
     
    10099    public function get_core_site_tables( $do_prefix = TRUE ) {
    101100
    102         $cache_key = "site-core-{$this->site_id}";
     101        $cache_key = "site-core-{$this->site_id}-"
     102            . ( $do_prefix ? 1 : 0 );
    103103        $cache     = wp_cache_get( $cache_key, $this->cache_group );
    104104
  • multilingual-press/trunk/inc/core/feature.nav-menu.php

    r996646 r1007975  
    88function mlp_nav_menu_init( Inpsyde_Property_List_Interface $data ) {
    99
    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    );
    1114
    1215    if ( is_admin() )
  • multilingual-press/trunk/inc/core/feature.widget.php

    r996646 r1007975  
    11<?php # -*- coding: utf-8 -*-
    22
     3add_action( 'inpsyde_mlp_init', 'mlp_widget_setup' );
     4
    35add_action( 'widgets_init', array ( 'Mlp_Widget', 'widget_register' ) );
     6
     7/**
     8 * @param Inpsyde_Property_List_Interface $plugin_data
     9 * @return void
     10 */
     11function 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  
    2121
    2222    /**
     23     * @type Mlp_Assets_Interface
     24     */
     25    private $assets;
     26
     27    /**
    2328     * Constructor
    2429     *
    2530     * @param   Mlp_Module_Manager_Interface $modules
     31     * @param   Mlp_Assets_Interface         $assets
    2632     */
    27     public function __construct( Mlp_Module_Manager_Interface $modules ) {
     33    public function __construct( Mlp_Module_Manager_Interface $modules, Mlp_Assets_Interface $assets ) {
    2834        $this->modules = $modules;
     35        $this->assets = $assets;
    2936    }
    3037
     
    6370        );
    6471
    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' ) );
    8173    }
    8274
  • multilingual-press/trunk/inc/core/installation/Mlp_Update_Plugin_Data.php

    r999339 r1007975  
    8080        if ( Mlp_Version_Number_Interface::FALLBACK_VERSION === $this->last_version )
    8181            $this->update_plugin_data( 1 );
    82 
    83         $this->update_plugin_data( $this->last_version );
     82        else
     83            $this->update_plugin_data( $this->last_version );
    8484    }
    8585
     
    125125
    126126            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 );
    130130        }
    131131    }
     
    195195     * Install plugin tables.
    196196     *
    197      * @needs-refactoring
    198      * @return void
     197     * @return bool
    199198     */
    200199    public function install_plugin() {
     
    204203        $installer->install( new Mlp_Content_Relations_Schema( $this->wpdb ) );
    205204        $installer->install( new Mlp_Site_Relations_Schema( $this->wpdb ) );
     205
     206        return update_site_option( 'mlp_version', $this->plugin_data->version );
    206207    }
    207208}
  • multilingual-press/trunk/inc/core/language-api/Mlp_Language_Api.php

    r999339 r1007975  
    256256        );
    257257
     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
    258265        $icon = $this->get_flag_by_language( $data[ 'http_name' ], $site_id );
    259266
     
    287294        $file_name = $sub . '.gif';
    288295
    289         if ( is_readable( $this->data->flag_path . $file_name ) )
     296        if ( is_readable( "{$this->data->flag_path}/$file_name" ) )
    290297            return new Mlp_Url( $this->data->flag_url . $file_name );
    291298
     
    361368            return array();
    362369
    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        }
    367385
    368386        $values = array_values( $tags );
     
    370388
    371389        $sql = "
    372 SELECT `english_name`, `native_name`, `custom_name`, `is_rtl`, `http_name`, `priority`, `wp_locale`
     390SELECT `english_name`, `native_name`, `custom_name`, `is_rtl`, `http_name`, `priority`, `wp_locale`, `iso_639_1`
    373391FROM $this->table_name
    374 WHERE `http_name` IN( $values );";
     392WHERE `http_name` IN( $values )";
     393
     394        if ( ! empty ( $add_like ) ) {
     395            $sql .= " OR `iso_639_1` IN ('" . join("','", array_values( $add_like )) . "')";
     396        }
    375397
    376398        $results = $this->wpdb->get_results( $sql, ARRAY_A );
     
    380402            foreach ( $results as $arr ) {
    381403                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                ) {
    382409                    $languages[ $site ] += $arr;
    383410                }
  • multilingual-press/trunk/inc/core/language-api/Mlp_Language_Api_Interface.php

    r996646 r1007975  
    4444     *     - 'search_term'          if you want to translate a search
    4545     *     - 'post_type'            for post type archives
     46     *     - 'include_base'         bool. Include the base site in returned list
    4647     *
    4748     * @param  array $args Optional. If left out, some magic happens.
  • multilingual-press/trunk/inc/core/language-manager/Mlp_Language_Manager_Controller.php

    r996646 r1007975  
    116116        );
    117117
    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' ) );
    120119    }
    121120
     
    124123     */
    125124    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' );
    130127    }
    131128
  • multilingual-press/trunk/inc/core/nav-menu/Mlp_Language_Nav_Menu_Data.php

    r996646 r1007975  
    33 * Data read and write for backend nav menu management.
    44 *
    5  * @version 2014.07.15
     5 * @version 2014.10.10
    66 * @author  Inpsyde GmbH, toscho
    77 * @license GPL
     
    1111
    1212    /**
    13      * @var string
     13     * @type string
    1414     */
    1515    private $meta_key;
     
    1818     * Button id.
    1919     *
    20      * @var string
     20     * @type string
    2121     */
    2222    private $button_id = 'mlp_language';
    2323
    2424    /**
    25      * @var string
     25     * @type string
    2626     */
    2727    private $handle;
    2828
    2929    /**
    30      * @var Inpsyde_Nonce_Validator_Interface
     30     * @type Inpsyde_Nonce_Validator_Interface
    3131     */
    3232    private $nonce;
    3333
    3434    /**
    35      * @var string
    36      */
    37     private $js_url;
    38 
    39     /**
     35     * @type Mlp_Assets_Interface
     36     */
     37    private $assets;
     38
     39    /**
     40     * Constructor
     41     *
    4042     * @param string                            $handle
    4143     * @param string                            $meta_key
    4244     * @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,
    4748                                          $meta_key,
    4849        Inpsyde_Nonce_Validator_Interface $nonce,
    49                                           $js_url
     50        Mlp_Assets_Interface              $assets
    5051    ) {
    5152        $this->handle   = $handle;
    5253        $this->meta_key = $meta_key;
    5354        $this->nonce    = $nonce;
    54         $this->js_url   = $js_url . "nav_menu.js";
     55        $this->assets   = $assets;
    5556    }
    5657
     
    9293    public function register_script() {
    9394
    94         wp_register_script( $this->handle, $this->js_url, array( 'jquery' ), 1, TRUE );
     95        $this->assets->provide( array ( 'mlp_backend_js', 'mlp_backend_css' ) );
    9596    }
    9697
     
    103104        if ( 'nav-menus.php' !== $hook )
    104105            return;
    105 
    106         wp_enqueue_script( $this->handle );
    107106
    108107        $data = array (
     
    116115        $data[ 'nonce_name' ] = $this->nonce->get_name();
    117116
    118         wp_localize_script( $this->handle, $this->handle, $data );
     117        wp_localize_script( 'mlp_backend_js', $this->handle, $data );
    119118    }
    120119
     
    183182     */
    184183    private function is_valid_blog_id( Array $titles, $blog_id ) {
     184
    185185        return isset ( $titles[ $blog_id ] ) && blog_exists( $blog_id );
    186186    }
     
    203203        );
    204204
    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        );
    207210        $menu_item = get_post( $item_id );
    208211
     
    220223
    221224        // 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;
    228231        // Replace the "Custom" in the management screen
    229232        $menu_item->type_label = esc_html__( 'Language', 'multilingualpress' );
    230233        $menu_item->classes[ ] = "blog-id-$blog_id";
    231234        $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, '/' );
    233236
    234237        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 );
    236240
    237241        return $menu_item;
  • multilingual-press/trunk/inc/core/nav-menu/Mlp_Nav_Menu_Controller.php

    r996646 r1007975  
    33 * Front controller for language menu items.
    44 *
    5  * @version 2014.05.13
     5 * @version 2014.10.10
    66 * @author  Inpsyde GmbH, toscho
    77 * @license GPL
     
    1212     * Basic identifier for all sort of operations.
    1313     *
    14      * @var string
     14     * @type string
    1515     */
    1616    private $handle   = 'mlp_nav_menu';
     
    1919     * Post meta key for nav items.
    2020     *
    21      * @var string
     21     * @type string
    2222     */
    2323    private $meta_key = '_blog_id';
     
    3333     * Backend view.
    3434     *
    35      * @var Mlp_Simple_Nav_Menu_Selectors
     35     * @type Mlp_Simple_Nav_Menu_Selectors
    3636     */
    3737    private $view;
    3838
    3939    /**
    40      *
    41      *
    42      * @type
     40     * @type Mlp_Language_Api_Interface
    4341     */
    4442    private $language_api;
    4543
    4644    /**
     45     * @type Mlp_Assets_Interface
     46     */
     47    private $assets;
     48
     49    /**
     50     * Constructor
     51     *
    4752     * @param Mlp_Language_Api_Interface $language_api
     53     * @param Mlp_Assets_Interface       $assets
    4854     */
    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    ) {
    5059
    5160        $this->language_api = $language_api;
     61        $this->assets       = $assets;
    5262    }
    5363
     
    6070    public function frontend_setup() {
    6171
    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
    6875        );
     76
     77        add_filter( 'wp_nav_menu_objects', array ( $frontend, 'filter_items' ) );
    6978    }
    7079
     
    9099    public function add_meta_box() {
    91100
     101        $title = esc_html__( 'Languages', 'multilingualpress' );
     102
    92103        add_meta_box(
    93104            $this->handle,
    94             __( 'Languages', 'multilingualpress' ),
     105            $title,
    95106            array ( $this->view, 'show_available_languages' ),
    96107            'nav-menus',
     
    104115     *
    105116     * @wp-hook inpsyde_mlp_loaded
    106      * @param string $js_url
    107117     * @return  void
    108118     */
    109     private function create_instances( $js_url ) {
     119    private function create_instances() {
    110120
    111         $nonce      = new Inpsyde_Nonce_Validator(
     121        $nonce = new Inpsyde_Nonce_Validator(
    112122            $this->handle
    113123        );
     
    116126            $this->meta_key,
    117127            $nonce,
    118             $js_url
     128            $this->assets
    119129        );
    120130        $this->view = new Mlp_Simple_Nav_Menu_Selectors(
     
    133143            array ( $this->data, 'register_script' )
    134144        );
     145
    135146        add_action(
    136147            'admin_enqueue_scripts',
    137148            array ( $this->data, 'load_script' )
    138149        );
     150
    139151        add_action(
    140152            "wp_ajax_$this->handle",
    141153            array ( $this->view, 'show_selected_languages' )
    142154        );
     155
    143156        add_action(
    144157            'admin_init',
  • multilingual-press/trunk/inc/core/nav-menu/Mlp_Nav_Menu_Frontend.php

    r996646 r1007975  
    4242    public function filter_items( Array $items ) {
    4343
    44         $translations = $this->language_api->get_translations(
    45             array ( 'strict' => FALSE )
     44        $args = array (
     45            'strict'       => FALSE,
     46            'include_base' => TRUE
    4647        );
     48        $translations = $this->language_api->get_translations( $args );
    4749
    4850        if ( empty ( $translations ) )
  • multilingual-press/trunk/inc/core/post-translator/Mlp_Translation_Metabox.php

    r996646 r1007975  
    132132                $this->register_metabox_per_language( $blog_id, $post );
    133133        }
     134
     135        $this->plugin_data->assets->provide( 'mlp_backend_css' );
     136        $this->plugin_data->assets->provide( 'mlp_backend_js' );
    134137    }
    135138
  • multilingual-press/trunk/inc/core/types/Mlp_Language.php

    r996646 r1007975  
    6464
    6565        if ( $name === 'language_long' )
    66             return $this->names[ 'http_name'];
     66            return $this->names[ 'http_name' ];
    6767
    6868        // $name is empty or invalid, so ...
  • multilingual-press/trunk/multilingual-press.php

    r999339 r1007975  
    66 * Author:      Inpsyde GmbH
    77 * Author URI:  http://inpsyde.com
    8  * Version:     2.1.1
     8 * Version:     2.1.2
    99 * Text Domain: multilingualpress
    1010 * Domain Path: /languages
     
    2626    global $wp_version, $wpdb, $pagenow;
    2727
    28     $path   = plugin_dir_path( __FILE__ );
     28    $plugin_path   = plugin_dir_path( __FILE__ );
     29    $plugin_url    = plugins_url( '/', __FILE__ );
    2930
    3031    if ( ! class_exists( 'Mlp_Load_Controller' ) )
    31         require $path . 'inc/autoload/Mlp_Load_Controller.php';
     32        require $plugin_path . 'inc/autoload/Mlp_Load_Controller.php';
    3233
    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;
    3538
    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    }
    3848    $data->plugin_file_path = __FILE__;
    3949    $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/";
    4650
    4751    $headers = get_file_data(
  • multilingual-press/trunk/readme.txt

    r999645 r1007975  
    100100
    101101== 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.
    102110
    103111= 2.1.1 =
Note: See TracChangeset for help on using the changeset viewer.