• 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/media/class-wpml-attachment-action.php
    Артем ШиряевАртем Ширяев committed 554847ddcb906 Apr 2021
    Raw file
    Source viewDiff to previous
     
    1
    <?php
    2
    ​
    3
    use WPML\FP\Str;
    4
    ​
    5
    /**
    6
     * WPML_Attachment_Action class file.
    7
     *
    8
     * @package WPML
    9
     */
    10
    ​
    11
    /**
    12
     * Class WPML_Attachment_Action
    13
     */
    14
    class WPML_Attachment_Action implements IWPML_Action {
    15
    ​
    16
        /**
    17
         * SitePress instance.
    18
         *
    19
         * @var SitePress
    20
         */
    21
        private $sitepress;
    22
    ​
    23
        /**
    24
         * Wpdb instance.
    25
         *
    26
         * @var wpdb
    27
         */
    28
        private $wpdb;
    29
    ​
    30
        /**
    31
         * WPML_Attachment_Action constructor.
    32
         *
    33
         * @param SitePress $sitepress SitePress instance.
    34
         * @param wpdb      $wpdb      wpdb instance.
    35
         */
    36
        public function __construct( SitePress $sitepress, wpdb $wpdb ) {
    37
            $this->sitepress = $sitepress;
    38
            $this->wpdb      = $wpdb;
    39
        }
    40
    ​
    41
        /**
    42
         * Add hooks.
    43
         */
    44
        public function add_hooks() {
    45
            if ( $this->is_admin_or_xmlrpc() && ! $this->is_uploading_plugin_or_theme() ) {
    46
    ​
    47
                $active_languages = $this->sitepress->get_active_languages();
    48
    ​
    49
                if ( count( $active_languages ) > 1 ) {
    50
                    add_filter( 'views_upload', array( $this, 'views_upload_actions' ) );
    51
                }
    52
            }
    53
    ​
    54
            add_filter( 'attachment_link', array( $this->sitepress, 'convert_url' ), 10, 1 );
    55
            add_filter( 'wp_delete_file', array( $this, 'delete_file_filter' ) );
    56
        }
    57
    ​
    58
        /**
    59
         * Check if we are in site console or xmlrpc request is active.
    60
         *
    61
         * @return bool
    62
         */
    63
        private function is_admin_or_xmlrpc() {
    • 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.