• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
    • Help
      • Online help
      • Learn Git
      • Welcome to Bitbucket
      • Keyboard shortcuts
    • Log In
    Blackrock
    1. Blackrock

    main

    Public
    Actions
    • Clone

    Learn more about cloning repositories

    You have read-only access

    Navigation
    • Source
    • Commits
    • Branches
    • All Branches Graph
    • Graphs
    • Forks
    1. Blackrock
    2. main

    Source

    main/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/class-wpml-ls-widget.php
    Артем ШиряевАртем Ширяев committed 554847ddcb906 Apr 2021
    Raw file
    Source viewDiff to previous
            $number                   = isset( $widget_id ) ? $this->get_number_from_widget_id( $widget_id ) : $this->number;
     
    1
    <?php
    2
    ​
    3
    use WPML\FP\Obj;
    4
    ​
    5
    class WPML_LS_Widget extends WP_Widget {
    6
    ​
    7
        const SLUG        = 'icl_lang_sel_widget';
    8
        const ANCHOR_BASE = '#sidebars/';
    9
    ​
    10
        public function __construct() {
    11
            parent::__construct(
    12
                self::SLUG, // Base ID
    13
                __( 'Language Switcher', 'sitepress' ), // Name
    14
                array(
    15
                    'description' => __( 'Language Switcher', 'sitepress' ),
    16
                )
    17
            );
    18
    ​
    19
            add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts_action' ) );
    20
        }
    21
    ​
    22
        public static function register() {
    23
            register_widget( __CLASS__ );
    24
        }
    25
    ​
    26
        /**
    27
         * @param string $hook
    28
         */
    29
        public function admin_enqueue_scripts_action( $hook ) {
    30
            global $sitepress;
    31
    ​
    32
            if ( 'widgets.php' === $hook ) {
    33
                $suffix = $sitepress->get_wp_api()->constant( 'SCRIPT_DEBUG' ) ? '' : '.min';
    34
                wp_enqueue_script( 'wpml-widgets', ICL_PLUGIN_URL . '/res/js/widgets' . $suffix . '.js', array( 'jquery' ) );
    35
            }
    36
        }
    37
    ​
    38
        /**
    39
         * @param array<string,mixed> $args
    40
         * @param array               $instance
    41
         */
    42
        public function widget( $args, $instance ) {
    43
            /* @var WPML_Language_Switcher $wpml_language_switcher */
    44
            global $wpml_language_switcher;
    45
    ​
    46
            $sidebar = isset( $args['id'] ) ? $args['id'] : '';
    47
    ​
    48
            /* @var WPML_LS_Slot $slot */
    49
            $slot = $wpml_language_switcher->get_slot( 'sidebars', $sidebar );
    50
    ​
    51
            if ( ! $slot instanceof WPML_LS_Sidebar_Slot ) {
    52
                $instanceSlot = Obj::prop( 'slot', $instance );
    53
                $slot         = $instanceSlot instanceof WPML_LS_Sidebar_Slot ? $instanceSlot : $slot;
    54
            }
    55
    ​
    56
            $ret  = $wpml_language_switcher->render( $slot );
    57
    ​
    58
            if ( $ret ) {
    59
    ​
    60
                if ( $slot->get( 'widget_title' ) ) {
    61
                    remove_filter( 'widget_title', 'icl_sw_filters_widget_title', 0 );
    62
    ​
    63
                    $ret = $args['before_title'] . apply_filters( 'widget_title', $slot->get( 'widget_title' ) )
    • Git repository management for enterprise teams powered by Atlassian Bitbucket
    • Atlassian Bitbucket v5.10.1
    • Documentation
    • Contact Support
    • Request a feature
    • About
    • Contact Atlassian
    Atlassian

    Everything looks good. Well let you know here if theres anything you should know about.