| Server IP : 27.254.66.5 / Your IP : 216.73.217.39 Web Server : Apache/2 System : Linux cs82.hostneverdie.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 User : technic2 ( 1951) PHP Version : 7.4.30 Disable Function : apache_child_terminate, apache_setenv, define_syslog_variables, escapeshellarg, escapeshellcmd,exec, fp, fput, highlight_file, ini_alter, ini_restore, inject_code, passthru,phpAds_remoteInfo, phpAds_XmlRpc,phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid,posix_setuid, posix_setuid, posix_uname,proc_open,proc_close, proc_get_status, proc_nice, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode, show_source,sleep,pcntl_exec,virtual,suexec,dbmopen,dl,symlink,disk_free_space,diskfreespace,leak MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/technic2/public_html/old-website/wp-content/plugins/jetpack/ |
Upload File : |
<?php
/**
* Allows viewing posts on the frontend when the user is not logged in.
*/
class Jetpack_Frame_Nonce_Preview {
static $instance = null;
/**
* Returns the single instance of the Jetpack_Frame_Nonce_Preview object
*
* @since 4.3.0
*
* @return Jetpack_Frame_Nonce_Preview
**/
public static function get_instance() {
if ( ! is_null( self::$instance ) ) {
return self::$instance;
}
return self::$instance = new Jetpack_Frame_Nonce_Preview();
}
function __construct() {
if ( isset( $_GET['frame-nonce'] ) && ! is_admin() ) {
add_filter( 'pre_get_posts', array( $this, 'maybe_display_post' ) );
}
// autosave previews are validated differently
if ( isset( $_GET[ 'frame-nonce' ] ) && isset( $_GET[ 'preview_id' ] ) && isset( $_GET[ 'preview_nonce' ] ) ) {
remove_action( 'init', '_show_post_preview' );
add_action( 'init', array( $this, 'handle_autosave_nonce_validation' ) );
}
}
/**
* Verify that frame nonce exists, and if so, validate the nonce by calling WP.com.
*
* @since 4.3.0
*
* @return bool
*/
public function is_frame_nonce_valid() {
if ( empty( $_GET[ 'frame-nonce' ] ) ) {
return false;
}
Jetpack::load_xml_rpc_client();
$xml = new Jetpack_IXR_Client();
$xml->query( 'jetpack.verifyFrameNonce', sanitize_key( $_GET['frame-nonce'] ) );
if ( $xml->isError() ) {
return false;
}
return (bool) $xml->getResponse();
}
/**
* Conditionally add a hook on posts_results if this is the main query, a preview, and singular.
*
* @since 4.3.0
*
* @param WP_Query $query
*
* @return WP_Query
*/
public function maybe_display_post( $query ) {
if (
$query->is_main_query() &&
$query->is_preview() &&
$query->is_singular()
) {
add_filter( 'posts_results', array( $this, 'set_post_to_publish' ), 10, 2 );
}
return $query;
}
/**
* Conditionally set the first post to 'publish' if the frame nonce is valid and there is a post.
*
* @since 4.3.0
*
* @param array $posts
*
* @return array
*/
public function set_post_to_publish( $posts ) {
remove_filter( 'posts_results', array( $this, 'set_post_to_publish' ), 10, 2 );
if ( empty( $posts ) || is_user_logged_in() || ! $this->is_frame_nonce_valid() ) {
return $posts;
}
$posts[0]->post_status = 'publish';
// Disable comments and pings for this post.
add_filter( 'comments_open', '__return_false' );
add_filter( 'pings_open', '__return_false' );
return $posts;
}
/**
* Handle validation for autosave preview request
*
* @since 4.7.0
*
*/
public function handle_autosave_nonce_validation() {
if ( ! $this->is_frame_nonce_valid() ) {
wp_die( __( 'Sorry, you are not allowed to preview drafts.', 'jetpack' ) );
}
add_filter( 'the_preview', '_set_preview' );
}
}
Jetpack_Frame_Nonce_Preview::get_instance();