Esempio n. 1
0
 /**
  * constructor: setups filters and actions
  *
  * @since 1.2
  *
  * @param object $polylang
  */
 public function __construct(&$polylang)
 {
     parent::__construct($polylang);
     $this->options =& $polylang->options;
     $this->curlang =& $polylang->curlang;
     add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
     // filters posts, pages and media by language
     add_action('parse_query', array(&$this, 'parse_query'));
     // adds the Languages box in the 'Edit Post' and 'Edit Page' panels
     add_action('add_meta_boxes', array(&$this, 'add_meta_boxes'));
     // ajax response for changing the language in the post metabox
     add_action('wp_ajax_post_lang_choice', array(&$this, 'post_lang_choice'));
     add_action('wp_ajax_pll_posts_not_translated', array(&$this, 'ajax_posts_not_translated'));
     // adds actions and filters related to languages when creating, saving or deleting posts and pages
     add_action('save_post', array(&$this, 'save_post'), 21, 3);
     // priority 21 to come after advanced custom fields ( 20 ) and before the event calendar which breaks everything after 25
     add_filter('wp_insert_post_parent', array(&$this, 'wp_insert_post_parent'), 10, 4);
     add_action('before_delete_post', array(&$this, 'delete_post'));
     if ($this->options['media_support']) {
         add_action('delete_attachment', array(&$this, 'delete_post'));
         // action shared with media
     }
     // filters the pages by language in the parent dropdown list in the page attributes metabox
     add_filter('page_attributes_dropdown_pages_args', array(&$this, 'page_attributes_dropdown_pages_args'), 10, 2);
 }
 /**
  * Constructor: setups filters and actions
  *
  * @since 1.2
  *
  * @param object $polylang
  */
 public function __construct(&$polylang)
 {
     parent::__construct($polylang);
     // Adds the language field and translations tables in the 'Edit Media' panel
     add_filter('attachment_fields_to_edit', array(&$this, 'attachment_fields_to_edit'), 10, 2);
     // Adds actions related to languages when creating, saving or deleting media
     add_action('add_attachment', array(&$this, 'set_default_language'));
     add_filter('attachment_fields_to_save', array(&$this, 'save_media'), 10, 2);
     add_filter('wp_delete_file', array(&$this, 'wp_delete_file'));
     // Creates a media translation
     if (isset($_GET['action'], $_GET['new_lang'], $_GET['from_media']) && 'translate_media' === $_GET['action']) {
         add_action('admin_init', array(&$this, 'translate_media'));
     }
 }