• 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/widgets/class-wpml-widgets-support-backend.php
    Артем ШиряевАртем Ширяев committed 554847ddcb906 Apr 2021
    Raw file
    Source viewDiff to previous
                $new_language = filter_var( Obj::prop('wpml_language', $_POST), FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_NULL_ON_FAILURE );
     
    1
    <?php
    2
    ​
    3
    use \WPML\FP\Obj;
    4
    ​
    5
    /**
    6
     * This code is inspired by WPML Widgets (https://wordpress.org/plugins/wpml-widgets/),
    7
     * created by Jeroen Sormani
    8
     *
    9
     * @author OnTheGo Systems
    10
     */
    11
    class WPML_Widgets_Support_Backend implements IWPML_Action {
    12
        const NONCE = 'wpml-language-nonce';
    13
    ​
    14
        private $active_languages;
    15
        private $template_service;
    16
    ​
    17
        /**
    18
         * WPML_Widgets constructor.
    19
         *
    20
         * @param array                  $active_languages
    21
         * @param IWPML_Template_Service $template_service
    22
         */
    23
        public function __construct( array $active_languages, IWPML_Template_Service $template_service ) {
    24
            $this->active_languages = $active_languages;
    25
            $this->template_service = $template_service;
    26
        }
    27
    ​
    28
        public function add_hooks() {
    29
            add_action( 'in_widget_form', array( $this, 'language_selector' ), 10, 3 );
    30
            add_filter( 'widget_update_callback', array( $this, 'update' ), 10, 4 );
    31
        }
    32
    ​
    33
        /**
    34
         * @param WP_Widget|null $widget
    35
         * @param string|null    $form
    36
         * @param array          $instance
    37
         */
    38
        public function language_selector( $widget, $form, $instance ) {
    39
    ​
    40
            $languages        = $this->active_languages;
    41
            $languages['all'] = array(
    42
                'code'        => 'all',
    43
                'native_name' => __( 'All Languages', 'sitepress' ),
    44
            );
    45
    ​
    46
            $model = array(
    47
                'strings'           => array(
    48
                    'label' => __( 'Display on language:', 'sitepress' ),
    49
                ),
    50
                'languages'         => $languages,
    51
                'selected_language' => Obj::propOr( 'all', 'wpml_language', is_array( $instance ) ? $instance : [] ),
    52
                'nonce'             => wp_create_nonce( self::NONCE ),
    53
            );
    54
    ​
    55
            echo $this->template_service->show( $model, 'language-selector.twig' );
    56
        }
    57
    ​
    58
        /**
    59
         * @param array     $instance
    60
         * @param array     $new_instance
    61
         * @param array     $old_instance
    62
         * @param WP_Widget $widget_instance
    63
         *
    • 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.