PATH:
var
/
www
/
clients
/
client1
/
web1
/
web
/
wp-content
/
sitepress-multilingual-cms
/
classes
/
upgrade
/
commands
<?php class WPML_Upgrade_Display_Mode_For_Posts implements IWPML_Upgrade_Command { const DISPLAY_MODE_SETTING = 'show_untranslated_blog_posts'; /** @var SitePress */ private $sitepress; /** @var WPML_Settings_Helper */ private $settings; /** @var WPML_Notices */ private $wpml_notices; public function __construct( array $args ) { $this->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 ) ) { add_action( 'init', [ $this, 'add_notice' ] ); return false; } else { return true; } } public function add_notice() { $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 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 ); ?> <div class="js-main-content"> <h2><?php esc_html_e( 'Display mode for blog posts has changed', 'sitepress' ); ?></h2> <p><?php esc_html_e( 'Until now, your site was set to display "all blog posts", even if they are not translated. That feature is now replaced with a better and more complete translation mode.', 'sitepress' ); ?></p> <p><?php esc_html_e( "Which blog posts do you want to display on your site's translations?", 'sitepress' ); ?></p> <p><label><input type="radio" name="mode" value="display-as-translated"/> <?php esc_html_e( "Blog posts from the site's default language, or translations when they exist", 'sitepress' ); ?> </label></p> <p><label><input type="radio" name="mode" value="translate"/> <?php esc_html_e( "Only translated blog posts (never display posts from the default language on translation languages)", 'sitepress' ); ?> </label></p> <input type="button" class="button-primary" name="save" value="<?php esc_attr_e( 'Save' ); ?>" disabled="disabled"/> <?php wp_nonce_field( $action . '-nonce', $action . '-nonce' ); ?> </div> <div class="js-thankyou-content" style="display: none"> <p><?php echo sprintf( esc_html__( 'Thank you for choosing. You can always change your selection in %sPost Types Translation setup%s.', 'sitepress' ), '<a href="' . $setup_url . '">', '</a>' ); ?></p> </div> <script> jQuery( document ).ready( function ( $ ) { $( '.js-main-content' ).find( 'input[name=mode]' ).on( 'change', function ( e ) { $( '.js-main-content' ).find( 'input[name=save]' ).prop( 'disabled', false ); } ); $( '.js-main-content' ).find( 'input[name=save]' ).on( 'click', function ( e ) { $( this ).prop( 'disabled', true ); $.ajax( { url: ajaxurl, type: "POST", data: { action: '<?php echo $action; ?>', nonce: $( '#<?php echo $action; ?>-nonce' ).val(), mode: $( 'input[name=mode]:checked', '.js-main-content' ).val() }, success: function ( response ) { $( '.js-main-content' ).hide(); $( '.js-thankyou-content' ).show(); } } ); } ); } ); </script> <?php return ob_get_clean(); } }
[-] AddAteSyncCountToTranslationJob.php
[edit]
[-] AddCountryColumnToLanguages.php
[edit]
[-] class-wpml-upgrade-add-location-column-to-strings.php
[edit]
[-] class-wpml-upgrade-fix-non-admin-cap.php
[edit]
[-] class-wpml-tm-add-tp-revision-and-ts-status-columns-to-core-status.php
[edit]
[-] class-wpml-upgrade-media-duplication-in-core.php
[edit]
[-] class-wpml-upgrade-add-editor-column-to-icl-translate-job.php
[edit]
[-] class-wpml-tm-add-tp-revision-and-ts-status-columns-to-translation-status.php
[edit]
[-] class-wpml-add-uuid-column-to-translation-status.php
[edit]
[-] class-wpml-tm-upgrade-wpml-site-id-ate.php
[edit]
[-] class-wpml-upgrade-media-without-language.php
[edit]
[-] ResetTranslatorOfAutomaticJobs.php
[edit]
[+]
SynchronizeSourceIdOfATEJobs
[-] class-wpml-upgrade-add-wrap-column-to-strings.php
[edit]
[-] class-wpml-tm-add-tpid-column-to-translation-status.php
[edit]
[-] AddTranslationManagerCapToAdmin.php
[edit]
[-] AddContextIndexToStrings.php
[edit]
[-] class-wpml-upgrade-wpml-site-id-remaining.php
[edit]
[-] DropCodeLocaleIndexFromLocaleMap.php
[edit]
[-] class-wpml-upgrade-table-translate-job-for-3-9-0.php
[edit]
[-] AddAteCommunicationRetryColumnToTranslationStatus.php
[edit]
[-] AddStatusIndexToStringTranslations.php
[edit]
[-] class-disable-options-autoloading.php
[edit]
[+]
abstracts
[-] AddTMAllowedOption.php
[edit]
[-] AddReviewStatusColumnToTranslationStatus.php
[edit]
[-] class-wpml-upgrade-element-type-length-and-collation.php
[edit]
[-] AddStringPackageIdtIndexToStrings.php
[edit]
[-] class-wpml-tm-upgrade-service-redirect-to-field.php
[edit]
[-] wpml-upgrade-admin-users-languages.php
[edit]
[-] CreateAteDownloadQueueTable.php
[edit]
[-] RemoveRestDisabledNotice.php
[edit]
[-] AddAutomaticColumnToIclTranslateJob.php
[edit]
[-] class-wpml-tm-upgrade-translation-priorities-for-posts.php
[edit]
[-] class-wpml-tm-upgrade-default-editor-for-old-jobs.php
[edit]
[-] MigrateAteRepository.php
[edit]
[-] class-wpml-upgrade-add-word-count-column-to-strings.php
[edit]
[-] class-wpml-upgrade-remove-translation-services-transient.php
[edit]
[-] class-wpml-upgrade-display-mode-for-posts.php
[edit]
[-] wpml-tm-upgrade-cancel-orphan-jobs.php
[edit]
[+]
..
[-] AddPrimaryKeyToLocaleMap.php
[edit]
[-] ATEProxyUpdateRewriteRules.php
[edit]
[-] class-wpml-upgrade-wpml-site-id.php
[edit]
[-] class-wpml-upgrade-add-wrap-column-to-translate.php
[edit]
[-] wpml-upgrade-chinese-flags.php
[edit]
[-] RefreshTranslationServices.php
[edit]