• 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/woocommerce-multilingual/inc/class-wcml-resources.php
    Артем ШиряевАртем Ширяев committed 554847ddcb906 Apr 2021
    Raw file
    Source viewDiff to previous
     
    1
    <?php
    2
    ​
    3
    class WCML_Resources {
    4
    ​
    5
        private static $page;
    6
        private static $tab;
    7
        private static $is_wpml_wcml_page;
    8
        private static $pagenow;
    9
    ​
    10
        private static $woocommerce_wpml;
    11
        private static $sitepress;
    12
    ​
    13
        public static function add_hooks() {
    14
            add_action( 'admin_enqueue_scripts', [ __CLASS__, 'admin_scripts' ] );
    15
            add_action( 'wp_enqueue_scripts', [ __CLASS__, 'front_scripts' ] );
    16
        }
    17
    ​
    18
        /**
    19
         * @param woocommerce_wpml $woocommerce_wpml
    20
         * @param SitePress        $sitepress
    21
         */
    22
        public static function set_up_resources( $woocommerce_wpml, $sitepress ) {
    23
            global $pagenow;
    24
    ​
    25
            self::$woocommerce_wpml = $woocommerce_wpml;
    26
            self::$sitepress        = $sitepress;
    27
    ​
    28
            self::$page              = isset( $_GET['page'] ) ? $_GET['page'] : null;
    29
            self::$tab               = isset( $_GET['tab'] ) ? $_GET['tab'] : null;
    30
            self::$is_wpml_wcml_page = self::$page == 'wpml-wcml';
    31
            self::$pagenow           = $pagenow;
    32
    ​
    33
            self::load_css();
    34
    ​
    35
            $is_edit_product     = self::$pagenow == 'post.php' && isset( $_GET['post'] ) && get_post_type( $_GET['post'] ) == 'product';
    36
            $is_original_product = isset( $_GET['post'] ) && ! is_array( $_GET['post'] ) && self::$woocommerce_wpml->products->is_original_product( $_GET['post'] );
    37
            $is_new_product      = self::$pagenow == 'post-new.php' && isset( $_GET['source_lang'] ) && isset( $_GET['post_type'] ) && $_GET['post_type'] == 'product';
    38
    ​
    39
            if ( self::$woocommerce_wpml->is_wpml_prior_4_2() ) {
    40
                $is_using_native_editor = ! self::$woocommerce_wpml->settings['trnsl_interface'];
    41
            } else {
    42
                $tm_settings = $sitepress->get_setting( 'translation-management', [] );
    43
                if ( $is_edit_product ) {
    44
                    $is_using_native_editor = WPML_TM_Post_Edit_TM_Editor_Mode::is_using_tm_editor( self::$sitepress, filter_var( $_GET['post'], FILTER_SANITIZE_NUMBER_INT ) );
    45
                } else {
    46
                    $is_using_native_editor = isset( $tm_settings[ WPML_TM_Post_Edit_TM_Editor_Mode::TM_KEY_FOR_POST_TYPE_USE_NATIVE ]['product'] ) ? $tm_settings[ WPML_TM_Post_Edit_TM_Editor_Mode::TM_KEY_FOR_POST_TYPE_USE_NATIVE ]['product'] : false;
    47
    ​
    48
                    if ( ! $is_using_native_editor ) {
    49
                        $is_using_native_editor = isset( $tm_settings[ WPML_TM_Post_Edit_TM_Editor_Mode::TM_KEY_GLOBAL_USE_NATIVE ] ) ? $tm_settings[ WPML_TM_Post_Edit_TM_Editor_Mode::TM_KEY_GLOBAL_USE_NATIVE ] : false;
    50
                    }
    51
                }
    52
            }
    53
    ​
    54
            if ( ( $is_edit_product && ! $is_original_product ) || $is_new_product && $is_using_native_editor ) {
    55
                add_action( 'init', [ __CLASS__, 'load_lock_fields_js' ] );
    56
                add_action( 'admin_footer', [ __CLASS__, 'hidden_label' ] );
    57
            }
    58
        }
    59
    ​
    60
        private static function load_css() {
    61
    ​
    62
            if ( self::$is_wpml_wcml_page || self::$page == WPML_TM_FOLDER . '/menu/translations-queue.php' ) {
    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.