sitepress = $args[0]; $this->settings = $args[1]; $this->wpml_notices = $args[2]; } /** * @return bool */ public function run_admin() { if ( $this->sitepress->get_setting( self::DISPLAY_MODE_SETTING ) ) { $notice = $this->wpml_notices->create_notice( __CLASS__, $this->get_notice_content() ); $notice->add_display_callback( array( 'WPML_Notice_Show_On_Dashboard_And_WPML_Pages', 'is_on_page' ) ); $notice->set_css_class_types( 'info' ); $this->wpml_notices->add_notice( $notice ); return false; } else { return true; } } /** * @return bool */ public function run_ajax() { if ( isset( $_POST['mode'] ) ) { if ( 'translate' === $_POST['mode'] ) { $this->settings->set_post_type_translatable( 'post' ); $this->sitepress->set_setting( self::DISPLAY_MODE_SETTING, false, true ); $this->wpml_notices->remove_notice( 'default', __CLASS__ ); return true; } if ( 'display-as-translated' === $_POST['mode'] ) { $this->settings->set_post_type_display_as_translated( 'post' ); $this->sitepress->set_setting( self::DISPLAY_MODE_SETTING, false, true ); $this->wpml_notices->remove_notice( 'default', __CLASS__ ); return true; } } return false; } /** * @return bool */ public function run_frontend() { return false; } /** * @return array */ public function get_results() { return array(); } private function get_notice_content() { ob_start(); $action = str_replace( '_', '-', strtolower( __CLASS__ ) ); $setup_url = WPML_Admin_URL::multilingual_setup( 7 ); ?>