Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-inclu...
File: class-wp-customize-manager.php
$response['changeset_post_save_failure'] = $r->get_error_code();
[3000] Fix | Delete
return new WP_Error( 'changeset_post_save_failure', '', $response );
[3001] Fix | Delete
}
[3002] Fix | Delete
[3003] Fix | Delete
return $response;
[3004] Fix | Delete
}
[3005] Fix | Delete
[3006] Fix | Delete
/**
[3007] Fix | Delete
* Preserves the initial JSON post_content passed to save into the post.
[3008] Fix | Delete
*
[3009] Fix | Delete
* This is needed to prevent KSES and other {@see 'content_save_pre'} filters
[3010] Fix | Delete
* from corrupting JSON data.
[3011] Fix | Delete
*
[3012] Fix | Delete
* Note that WP_Customize_Manager::validate_setting_values() have already
[3013] Fix | Delete
* run on the setting values being serialized as JSON into the post content
[3014] Fix | Delete
* so it is pre-sanitized.
[3015] Fix | Delete
*
[3016] Fix | Delete
* Also, the sanitization logic is re-run through the respective
[3017] Fix | Delete
* WP_Customize_Setting::sanitize() method when being read out of the
[3018] Fix | Delete
* changeset, via WP_Customize_Manager::post_value(), and this sanitized
[3019] Fix | Delete
* value will also be sent into WP_Customize_Setting::update() for
[3020] Fix | Delete
* persisting to the DB.
[3021] Fix | Delete
*
[3022] Fix | Delete
* Multiple users can collaborate on a single changeset, where one user may
[3023] Fix | Delete
* have the unfiltered_html capability but another may not. A user with
[3024] Fix | Delete
* unfiltered_html may add a script tag to some field which needs to be kept
[3025] Fix | Delete
* intact even when another user updates the changeset to modify another field
[3026] Fix | Delete
* when they do not have unfiltered_html.
[3027] Fix | Delete
*
[3028] Fix | Delete
* @since 5.4.1
[3029] Fix | Delete
*
[3030] Fix | Delete
* @param array $data An array of slashed and processed post data.
[3031] Fix | Delete
* @param array $postarr An array of sanitized (and slashed) but otherwise unmodified post data.
[3032] Fix | Delete
* @param array $unsanitized_postarr An array of slashed yet *unsanitized* and unprocessed post data as originally passed to wp_insert_post().
[3033] Fix | Delete
* @return array Filtered post data.
[3034] Fix | Delete
*/
[3035] Fix | Delete
public function preserve_insert_changeset_post_content( $data, $postarr, $unsanitized_postarr ) {
[3036] Fix | Delete
if (
[3037] Fix | Delete
isset( $data['post_type'] ) &&
[3038] Fix | Delete
isset( $unsanitized_postarr['post_content'] ) &&
[3039] Fix | Delete
'customize_changeset' === $data['post_type'] ||
[3040] Fix | Delete
(
[3041] Fix | Delete
'revision' === $data['post_type'] &&
[3042] Fix | Delete
! empty( $data['post_parent'] ) &&
[3043] Fix | Delete
'customize_changeset' === get_post_type( $data['post_parent'] )
[3044] Fix | Delete
)
[3045] Fix | Delete
) {
[3046] Fix | Delete
$data['post_content'] = $unsanitized_postarr['post_content'];
[3047] Fix | Delete
}
[3048] Fix | Delete
return $data;
[3049] Fix | Delete
}
[3050] Fix | Delete
[3051] Fix | Delete
/**
[3052] Fix | Delete
* Trashes or deletes a changeset post.
[3053] Fix | Delete
*
[3054] Fix | Delete
* The following re-formulates the logic from `wp_trash_post()` as done in
[3055] Fix | Delete
* `wp_publish_post()`. The reason for bypassing `wp_trash_post()` is that it
[3056] Fix | Delete
* will mutate the the `post_content` and the `post_name` when they should be
[3057] Fix | Delete
* untouched.
[3058] Fix | Delete
*
[3059] Fix | Delete
* @since 4.9.0
[3060] Fix | Delete
*
[3061] Fix | Delete
* @see wp_trash_post()
[3062] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[3063] Fix | Delete
*
[3064] Fix | Delete
* @param int|WP_Post $post The changeset post.
[3065] Fix | Delete
* @return mixed A WP_Post object for the trashed post or an empty value on failure.
[3066] Fix | Delete
*/
[3067] Fix | Delete
public function trash_changeset_post( $post ) {
[3068] Fix | Delete
global $wpdb;
[3069] Fix | Delete
[3070] Fix | Delete
$post = get_post( $post );
[3071] Fix | Delete
[3072] Fix | Delete
if ( ! ( $post instanceof WP_Post ) ) {
[3073] Fix | Delete
return $post;
[3074] Fix | Delete
}
[3075] Fix | Delete
$post_id = $post->ID;
[3076] Fix | Delete
[3077] Fix | Delete
if ( ! EMPTY_TRASH_DAYS ) {
[3078] Fix | Delete
return wp_delete_post( $post_id, true );
[3079] Fix | Delete
}
[3080] Fix | Delete
[3081] Fix | Delete
if ( 'trash' === get_post_status( $post ) ) {
[3082] Fix | Delete
return false;
[3083] Fix | Delete
}
[3084] Fix | Delete
[3085] Fix | Delete
$previous_status = $post->post_status;
[3086] Fix | Delete
[3087] Fix | Delete
/** This filter is documented in wp-includes/post.php */
[3088] Fix | Delete
$check = apply_filters( 'pre_trash_post', null, $post, $previous_status );
[3089] Fix | Delete
if ( null !== $check ) {
[3090] Fix | Delete
return $check;
[3091] Fix | Delete
}
[3092] Fix | Delete
[3093] Fix | Delete
/** This action is documented in wp-includes/post.php */
[3094] Fix | Delete
do_action( 'wp_trash_post', $post_id, $previous_status );
[3095] Fix | Delete
[3096] Fix | Delete
add_post_meta( $post_id, '_wp_trash_meta_status', $previous_status );
[3097] Fix | Delete
add_post_meta( $post_id, '_wp_trash_meta_time', time() );
[3098] Fix | Delete
[3099] Fix | Delete
$new_status = 'trash';
[3100] Fix | Delete
$wpdb->update( $wpdb->posts, array( 'post_status' => $new_status ), array( 'ID' => $post->ID ) );
[3101] Fix | Delete
clean_post_cache( $post->ID );
[3102] Fix | Delete
[3103] Fix | Delete
$post->post_status = $new_status;
[3104] Fix | Delete
wp_transition_post_status( $new_status, $previous_status, $post );
[3105] Fix | Delete
[3106] Fix | Delete
/** This action is documented in wp-includes/post.php */
[3107] Fix | Delete
do_action( "edit_post_{$post->post_type}", $post->ID, $post );
[3108] Fix | Delete
[3109] Fix | Delete
/** This action is documented in wp-includes/post.php */
[3110] Fix | Delete
do_action( 'edit_post', $post->ID, $post );
[3111] Fix | Delete
[3112] Fix | Delete
/** This action is documented in wp-includes/post.php */
[3113] Fix | Delete
do_action( "save_post_{$post->post_type}", $post->ID, $post, true );
[3114] Fix | Delete
[3115] Fix | Delete
/** This action is documented in wp-includes/post.php */
[3116] Fix | Delete
do_action( 'save_post', $post->ID, $post, true );
[3117] Fix | Delete
[3118] Fix | Delete
/** This action is documented in wp-includes/post.php */
[3119] Fix | Delete
do_action( 'wp_insert_post', $post->ID, $post, true );
[3120] Fix | Delete
[3121] Fix | Delete
wp_after_insert_post( get_post( $post_id ), true, $post );
[3122] Fix | Delete
[3123] Fix | Delete
wp_trash_post_comments( $post_id );
[3124] Fix | Delete
[3125] Fix | Delete
/** This action is documented in wp-includes/post.php */
[3126] Fix | Delete
do_action( 'trashed_post', $post_id, $previous_status );
[3127] Fix | Delete
[3128] Fix | Delete
return $post;
[3129] Fix | Delete
}
[3130] Fix | Delete
[3131] Fix | Delete
/**
[3132] Fix | Delete
* Handles request to trash a changeset.
[3133] Fix | Delete
*
[3134] Fix | Delete
* @since 4.9.0
[3135] Fix | Delete
*/
[3136] Fix | Delete
public function handle_changeset_trash_request() {
[3137] Fix | Delete
if ( ! is_user_logged_in() ) {
[3138] Fix | Delete
wp_send_json_error( 'unauthenticated' );
[3139] Fix | Delete
}
[3140] Fix | Delete
[3141] Fix | Delete
if ( ! $this->is_preview() ) {
[3142] Fix | Delete
wp_send_json_error( 'not_preview' );
[3143] Fix | Delete
}
[3144] Fix | Delete
[3145] Fix | Delete
if ( ! check_ajax_referer( 'trash_customize_changeset', 'nonce', false ) ) {
[3146] Fix | Delete
wp_send_json_error(
[3147] Fix | Delete
array(
[3148] Fix | Delete
'code' => 'invalid_nonce',
[3149] Fix | Delete
'message' => __( 'There was an authentication problem. Please reload and try again.' ),
[3150] Fix | Delete
)
[3151] Fix | Delete
);
[3152] Fix | Delete
}
[3153] Fix | Delete
[3154] Fix | Delete
$changeset_post_id = $this->changeset_post_id();
[3155] Fix | Delete
[3156] Fix | Delete
if ( ! $changeset_post_id ) {
[3157] Fix | Delete
wp_send_json_error(
[3158] Fix | Delete
array(
[3159] Fix | Delete
'message' => __( 'No changes saved yet, so there is nothing to trash.' ),
[3160] Fix | Delete
'code' => 'non_existent_changeset',
[3161] Fix | Delete
)
[3162] Fix | Delete
);
[3163] Fix | Delete
return;
[3164] Fix | Delete
}
[3165] Fix | Delete
[3166] Fix | Delete
if ( $changeset_post_id ) {
[3167] Fix | Delete
if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->delete_post, $changeset_post_id ) ) {
[3168] Fix | Delete
wp_send_json_error(
[3169] Fix | Delete
array(
[3170] Fix | Delete
'code' => 'changeset_trash_unauthorized',
[3171] Fix | Delete
'message' => __( 'Unable to trash changes.' ),
[3172] Fix | Delete
)
[3173] Fix | Delete
);
[3174] Fix | Delete
}
[3175] Fix | Delete
[3176] Fix | Delete
$lock_user = (int) wp_check_post_lock( $changeset_post_id );
[3177] Fix | Delete
[3178] Fix | Delete
if ( $lock_user && get_current_user_id() !== $lock_user ) {
[3179] Fix | Delete
wp_send_json_error(
[3180] Fix | Delete
array(
[3181] Fix | Delete
'code' => 'changeset_locked',
[3182] Fix | Delete
'message' => __( 'Changeset is being edited by other user.' ),
[3183] Fix | Delete
'lockUser' => $this->get_lock_user_data( $lock_user ),
[3184] Fix | Delete
)
[3185] Fix | Delete
);
[3186] Fix | Delete
}
[3187] Fix | Delete
}
[3188] Fix | Delete
[3189] Fix | Delete
if ( 'trash' === get_post_status( $changeset_post_id ) ) {
[3190] Fix | Delete
wp_send_json_error(
[3191] Fix | Delete
array(
[3192] Fix | Delete
'message' => __( 'Changes have already been trashed.' ),
[3193] Fix | Delete
'code' => 'changeset_already_trashed',
[3194] Fix | Delete
)
[3195] Fix | Delete
);
[3196] Fix | Delete
return;
[3197] Fix | Delete
}
[3198] Fix | Delete
[3199] Fix | Delete
$r = $this->trash_changeset_post( $changeset_post_id );
[3200] Fix | Delete
if ( ! ( $r instanceof WP_Post ) ) {
[3201] Fix | Delete
wp_send_json_error(
[3202] Fix | Delete
array(
[3203] Fix | Delete
'code' => 'changeset_trash_failure',
[3204] Fix | Delete
'message' => __( 'Unable to trash changes.' ),
[3205] Fix | Delete
)
[3206] Fix | Delete
);
[3207] Fix | Delete
}
[3208] Fix | Delete
[3209] Fix | Delete
wp_send_json_success(
[3210] Fix | Delete
array(
[3211] Fix | Delete
'message' => __( 'Changes trashed successfully.' ),
[3212] Fix | Delete
)
[3213] Fix | Delete
);
[3214] Fix | Delete
}
[3215] Fix | Delete
[3216] Fix | Delete
/**
[3217] Fix | Delete
* Re-maps 'edit_post' meta cap for a customize_changeset post to be the same as 'customize' maps.
[3218] Fix | Delete
*
[3219] Fix | Delete
* There is essentially a "meta meta" cap in play here, where 'edit_post' meta cap maps to
[3220] Fix | Delete
* the 'customize' meta cap which then maps to 'edit_theme_options'. This is currently
[3221] Fix | Delete
* required in core for `wp_create_post_autosave()` because it will call
[3222] Fix | Delete
* `_wp_translate_postdata()` which in turn will check if a user can 'edit_post', but the
[3223] Fix | Delete
* the caps for the customize_changeset post type are all mapping to the meta capability.
[3224] Fix | Delete
* This should be able to be removed once #40922 is addressed in core.
[3225] Fix | Delete
*
[3226] Fix | Delete
* @since 4.9.0
[3227] Fix | Delete
*
[3228] Fix | Delete
* @link https://core.trac.wordpress.org/ticket/40922
[3229] Fix | Delete
* @see WP_Customize_Manager::save_changeset_post()
[3230] Fix | Delete
* @see _wp_translate_postdata()
[3231] Fix | Delete
*
[3232] Fix | Delete
* @param string[] $caps Array of the user's capabilities.
[3233] Fix | Delete
* @param string $cap Capability name.
[3234] Fix | Delete
* @param int $user_id The user ID.
[3235] Fix | Delete
* @param array $args Adds the context to the cap. Typically the object ID.
[3236] Fix | Delete
* @return array Capabilities.
[3237] Fix | Delete
*/
[3238] Fix | Delete
public function grant_edit_post_capability_for_changeset( $caps, $cap, $user_id, $args ) {
[3239] Fix | Delete
if ( 'edit_post' === $cap && ! empty( $args[0] ) && 'customize_changeset' === get_post_type( $args[0] ) ) {
[3240] Fix | Delete
$post_type_obj = get_post_type_object( 'customize_changeset' );
[3241] Fix | Delete
$caps = map_meta_cap( $post_type_obj->cap->$cap, $user_id );
[3242] Fix | Delete
}
[3243] Fix | Delete
return $caps;
[3244] Fix | Delete
}
[3245] Fix | Delete
[3246] Fix | Delete
/**
[3247] Fix | Delete
* Marks the changeset post as being currently edited by the current user.
[3248] Fix | Delete
*
[3249] Fix | Delete
* @since 4.9.0
[3250] Fix | Delete
*
[3251] Fix | Delete
* @param int $changeset_post_id Changeset post ID.
[3252] Fix | Delete
* @param bool $take_over Whether to take over the changeset. Default false.
[3253] Fix | Delete
*/
[3254] Fix | Delete
public function set_changeset_lock( $changeset_post_id, $take_over = false ) {
[3255] Fix | Delete
if ( $changeset_post_id ) {
[3256] Fix | Delete
$can_override = ! (bool) get_post_meta( $changeset_post_id, '_edit_lock', true );
[3257] Fix | Delete
[3258] Fix | Delete
if ( $take_over ) {
[3259] Fix | Delete
$can_override = true;
[3260] Fix | Delete
}
[3261] Fix | Delete
[3262] Fix | Delete
if ( $can_override ) {
[3263] Fix | Delete
$lock = sprintf( '%s:%s', time(), get_current_user_id() );
[3264] Fix | Delete
update_post_meta( $changeset_post_id, '_edit_lock', $lock );
[3265] Fix | Delete
} else {
[3266] Fix | Delete
$this->refresh_changeset_lock( $changeset_post_id );
[3267] Fix | Delete
}
[3268] Fix | Delete
}
[3269] Fix | Delete
}
[3270] Fix | Delete
[3271] Fix | Delete
/**
[3272] Fix | Delete
* Refreshes changeset lock with the current time if current user edited the changeset before.
[3273] Fix | Delete
*
[3274] Fix | Delete
* @since 4.9.0
[3275] Fix | Delete
*
[3276] Fix | Delete
* @param int $changeset_post_id Changeset post ID.
[3277] Fix | Delete
*/
[3278] Fix | Delete
public function refresh_changeset_lock( $changeset_post_id ) {
[3279] Fix | Delete
if ( ! $changeset_post_id ) {
[3280] Fix | Delete
return;
[3281] Fix | Delete
}
[3282] Fix | Delete
[3283] Fix | Delete
$lock = get_post_meta( $changeset_post_id, '_edit_lock', true );
[3284] Fix | Delete
$lock = explode( ':', $lock );
[3285] Fix | Delete
[3286] Fix | Delete
if ( $lock && ! empty( $lock[1] ) ) {
[3287] Fix | Delete
$user_id = (int) $lock[1];
[3288] Fix | Delete
$current_user_id = get_current_user_id();
[3289] Fix | Delete
if ( $user_id === $current_user_id ) {
[3290] Fix | Delete
$lock = sprintf( '%s:%s', time(), $user_id );
[3291] Fix | Delete
update_post_meta( $changeset_post_id, '_edit_lock', $lock );
[3292] Fix | Delete
}
[3293] Fix | Delete
}
[3294] Fix | Delete
}
[3295] Fix | Delete
[3296] Fix | Delete
/**
[3297] Fix | Delete
* Filters heartbeat settings for the Customizer.
[3298] Fix | Delete
*
[3299] Fix | Delete
* @since 4.9.0
[3300] Fix | Delete
*
[3301] Fix | Delete
* @global string $pagenow The filename of the current screen.
[3302] Fix | Delete
*
[3303] Fix | Delete
* @param array $settings Current settings to filter.
[3304] Fix | Delete
* @return array Heartbeat settings.
[3305] Fix | Delete
*/
[3306] Fix | Delete
public function add_customize_screen_to_heartbeat_settings( $settings ) {
[3307] Fix | Delete
global $pagenow;
[3308] Fix | Delete
[3309] Fix | Delete
if ( 'customize.php' === $pagenow ) {
[3310] Fix | Delete
$settings['screenId'] = 'customize';
[3311] Fix | Delete
}
[3312] Fix | Delete
[3313] Fix | Delete
return $settings;
[3314] Fix | Delete
}
[3315] Fix | Delete
[3316] Fix | Delete
/**
[3317] Fix | Delete
* Gets lock user data.
[3318] Fix | Delete
*
[3319] Fix | Delete
* @since 4.9.0
[3320] Fix | Delete
*
[3321] Fix | Delete
* @param int $user_id User ID.
[3322] Fix | Delete
* @return array|null User data formatted for client.
[3323] Fix | Delete
*/
[3324] Fix | Delete
protected function get_lock_user_data( $user_id ) {
[3325] Fix | Delete
if ( ! $user_id ) {
[3326] Fix | Delete
return null;
[3327] Fix | Delete
}
[3328] Fix | Delete
[3329] Fix | Delete
$lock_user = get_userdata( $user_id );
[3330] Fix | Delete
[3331] Fix | Delete
if ( ! $lock_user ) {
[3332] Fix | Delete
return null;
[3333] Fix | Delete
}
[3334] Fix | Delete
[3335] Fix | Delete
return array(
[3336] Fix | Delete
'id' => $lock_user->ID,
[3337] Fix | Delete
'name' => $lock_user->display_name,
[3338] Fix | Delete
'avatar' => get_avatar_url( $lock_user->ID, array( 'size' => 128 ) ),
[3339] Fix | Delete
);
[3340] Fix | Delete
}
[3341] Fix | Delete
[3342] Fix | Delete
/**
[3343] Fix | Delete
* Checks locked changeset with heartbeat API.
[3344] Fix | Delete
*
[3345] Fix | Delete
* @since 4.9.0
[3346] Fix | Delete
*
[3347] Fix | Delete
* @param array $response The Heartbeat response.
[3348] Fix | Delete
* @param array $data The $_POST data sent.
[3349] Fix | Delete
* @param string $screen_id The screen id.
[3350] Fix | Delete
* @return array The Heartbeat response.
[3351] Fix | Delete
*/
[3352] Fix | Delete
public function check_changeset_lock_with_heartbeat( $response, $data, $screen_id ) {
[3353] Fix | Delete
if ( isset( $data['changeset_uuid'] ) ) {
[3354] Fix | Delete
$changeset_post_id = $this->find_changeset_post_id( $data['changeset_uuid'] );
[3355] Fix | Delete
} else {
[3356] Fix | Delete
$changeset_post_id = $this->changeset_post_id();
[3357] Fix | Delete
}
[3358] Fix | Delete
[3359] Fix | Delete
if (
[3360] Fix | Delete
array_key_exists( 'check_changeset_lock', $data )
[3361] Fix | Delete
&& 'customize' === $screen_id
[3362] Fix | Delete
&& $changeset_post_id
[3363] Fix | Delete
&& current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $changeset_post_id )
[3364] Fix | Delete
) {
[3365] Fix | Delete
$lock_user_id = wp_check_post_lock( $changeset_post_id );
[3366] Fix | Delete
[3367] Fix | Delete
if ( $lock_user_id ) {
[3368] Fix | Delete
$response['customize_changeset_lock_user'] = $this->get_lock_user_data( $lock_user_id );
[3369] Fix | Delete
} else {
[3370] Fix | Delete
[3371] Fix | Delete
// Refreshing time will ensure that the user is sitting on customizer and has not closed the customizer tab.
[3372] Fix | Delete
$this->refresh_changeset_lock( $changeset_post_id );
[3373] Fix | Delete
}
[3374] Fix | Delete
}
[3375] Fix | Delete
[3376] Fix | Delete
return $response;
[3377] Fix | Delete
}
[3378] Fix | Delete
[3379] Fix | Delete
/**
[3380] Fix | Delete
* Removes changeset lock when take over request is sent via Ajax.
[3381] Fix | Delete
*
[3382] Fix | Delete
* @since 4.9.0
[3383] Fix | Delete
*/
[3384] Fix | Delete
public function handle_override_changeset_lock_request() {
[3385] Fix | Delete
if ( ! $this->is_preview() ) {
[3386] Fix | Delete
wp_send_json_error( 'not_preview', 400 );
[3387] Fix | Delete
}
[3388] Fix | Delete
[3389] Fix | Delete
if ( ! check_ajax_referer( 'customize_override_changeset_lock', 'nonce', false ) ) {
[3390] Fix | Delete
wp_send_json_error(
[3391] Fix | Delete
array(
[3392] Fix | Delete
'code' => 'invalid_nonce',
[3393] Fix | Delete
'message' => __( 'Security check failed.' ),
[3394] Fix | Delete
)
[3395] Fix | Delete
);
[3396] Fix | Delete
}
[3397] Fix | Delete
[3398] Fix | Delete
$changeset_post_id = $this->changeset_post_id();
[3399] Fix | Delete
[3400] Fix | Delete
if ( empty( $changeset_post_id ) ) {
[3401] Fix | Delete
wp_send_json_error(
[3402] Fix | Delete
array(
[3403] Fix | Delete
'code' => 'no_changeset_found_to_take_over',
[3404] Fix | Delete
'message' => __( 'No changeset found to take over' ),
[3405] Fix | Delete
)
[3406] Fix | Delete
);
[3407] Fix | Delete
}
[3408] Fix | Delete
[3409] Fix | Delete
if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $changeset_post_id ) ) {
[3410] Fix | Delete
wp_send_json_error(
[3411] Fix | Delete
array(
[3412] Fix | Delete
'code' => 'cannot_remove_changeset_lock',
[3413] Fix | Delete
'message' => __( 'Sorry, you are not allowed to take over.' ),
[3414] Fix | Delete
)
[3415] Fix | Delete
);
[3416] Fix | Delete
}
[3417] Fix | Delete
[3418] Fix | Delete
$this->set_changeset_lock( $changeset_post_id, true );
[3419] Fix | Delete
[3420] Fix | Delete
wp_send_json_success( 'changeset_taken_over' );
[3421] Fix | Delete
}
[3422] Fix | Delete
[3423] Fix | Delete
/**
[3424] Fix | Delete
* Determines whether a changeset revision should be made.
[3425] Fix | Delete
*
[3426] Fix | Delete
* @since 4.7.0
[3427] Fix | Delete
* @var bool
[3428] Fix | Delete
*/
[3429] Fix | Delete
protected $store_changeset_revision;
[3430] Fix | Delete
[3431] Fix | Delete
/**
[3432] Fix | Delete
* Filters whether a changeset has changed to create a new revision.
[3433] Fix | Delete
*
[3434] Fix | Delete
* Note that this will not be called while a changeset post remains in auto-draft status.
[3435] Fix | Delete
*
[3436] Fix | Delete
* @since 4.7.0
[3437] Fix | Delete
*
[3438] Fix | Delete
* @param bool $post_has_changed Whether the post has changed.
[3439] Fix | Delete
* @param WP_Post $latest_revision The latest revision post object.
[3440] Fix | Delete
* @param WP_Post $post The post object.
[3441] Fix | Delete
* @return bool Whether a revision should be made.
[3442] Fix | Delete
*/
[3443] Fix | Delete
public function _filter_revision_post_has_changed( $post_has_changed, $latest_revision, $post ) {
[3444] Fix | Delete
unset( $latest_revision );
[3445] Fix | Delete
if ( 'customize_changeset' === $post->post_type ) {
[3446] Fix | Delete
$post_has_changed = $this->store_changeset_revision;
[3447] Fix | Delete
}
[3448] Fix | Delete
return $post_has_changed;
[3449] Fix | Delete
}
[3450] Fix | Delete
[3451] Fix | Delete
/**
[3452] Fix | Delete
* Publishes the values of a changeset.
[3453] Fix | Delete
*
[3454] Fix | Delete
* This will publish the values contained in a changeset, even changesets that do not
[3455] Fix | Delete
* correspond to current manager instance. This is called by
[3456] Fix | Delete
* `_wp_customize_publish_changeset()` when a customize_changeset post is
[3457] Fix | Delete
* transitioned to the `publish` status. As such, this method should not be
[3458] Fix | Delete
* called directly and instead `wp_publish_post()` should be used.
[3459] Fix | Delete
*
[3460] Fix | Delete
* Please note that if the settings in the changeset are for a non-activated
[3461] Fix | Delete
* theme, the theme must first be switched to (via `switch_theme()`) before
[3462] Fix | Delete
* invoking this method.
[3463] Fix | Delete
*
[3464] Fix | Delete
* @since 4.7.0
[3465] Fix | Delete
*
[3466] Fix | Delete
* @see _wp_customize_publish_changeset()
[3467] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[3468] Fix | Delete
*
[3469] Fix | Delete
* @param int $changeset_post_id ID for customize_changeset post. Defaults to the changeset for the current manager instance.
[3470] Fix | Delete
* @return true|WP_Error True or error info.
[3471] Fix | Delete
*/
[3472] Fix | Delete
public function _publish_changeset_values( $changeset_post_id ) {
[3473] Fix | Delete
global $wpdb;
[3474] Fix | Delete
[3475] Fix | Delete
$publishing_changeset_data = $this->get_changeset_post_data( $changeset_post_id );
[3476] Fix | Delete
if ( is_wp_error( $publishing_changeset_data ) ) {
[3477] Fix | Delete
return $publishing_changeset_data;
[3478] Fix | Delete
}
[3479] Fix | Delete
[3480] Fix | Delete
$changeset_post = get_post( $changeset_post_id );
[3481] Fix | Delete
[3482] Fix | Delete
/*
[3483] Fix | Delete
* Temporarily override the changeset context so that it will be read
[3484] Fix | Delete
* in calls to unsanitized_post_values() and so that it will be available
[3485] Fix | Delete
* on the $wp_customize object passed to hooks during the save logic.
[3486] Fix | Delete
*/
[3487] Fix | Delete
$previous_changeset_post_id = $this->_changeset_post_id;
[3488] Fix | Delete
$this->_changeset_post_id = $changeset_post_id;
[3489] Fix | Delete
$previous_changeset_uuid = $this->_changeset_uuid;
[3490] Fix | Delete
$this->_changeset_uuid = $changeset_post->post_name;
[3491] Fix | Delete
$previous_changeset_data = $this->_changeset_data;
[3492] Fix | Delete
$this->_changeset_data = $publishing_changeset_data;
[3493] Fix | Delete
[3494] Fix | Delete
// Parse changeset data to identify theme mod settings and user IDs associated with settings to be saved.
[3495] Fix | Delete
$setting_user_ids = array();
[3496] Fix | Delete
$theme_mod_settings = array();
[3497] Fix | Delete
$namespace_pattern = '/^(?P<stylesheet>.+?)::(?P<setting_id>.+)$/';
[3498] Fix | Delete
$matches = array();
[3499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function