'.esc_html__("Status: Template Mode", "accelerated-mobile-pages").' |'); $actions = array_merge( $actions, $amp_activate ); return $actions; } function amp_comment_mustache_script($data){ if(isset($data['amp_component_scripts']['amp-next-page'])){ unset($data['amp_component_scripts']['amp-next-page']); } if ( comments_open()){ if ( empty( $data['amp_component_scripts']['amp-mustache'] ) ) { $data['amp_component_scripts']['amp-mustache'] = 'https://cdn.ampproject.org/v0/amp-mustache-latest.js'; } if ( empty( $data['amp_component_scripts']['amp-form'] ) ) { $data['amp_component_scripts']['amp-form'] = 'https://cdn.ampproject.org/v0/amp-form-latest.js'; } } unset($data['amp_component_scripts']['amp-addthis']); return $data; } function amp_theme_ajaxcomments(){ global $redux_builder_amp; header("access-control-allow-credentials:true"); header("access-control-allow-headers:Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token"); /* phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated,WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized */ header("Access-Control-Allow-Origin:".esc_attr($_SERVER['HTTP_ORIGIN']) ); $siteUrl = parse_url( get_site_url() ); header("AMP-Access-Control-Allow-Source-Origin:".esc_attr($siteUrl['scheme']) . '://' . esc_attr($siteUrl['host']) ); header("access-control-expose-headers:AMP-Access-Control-Allow-Source-Origin"); header("Content-Type:application/json;charset=utf-8"); /* phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated,WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized */ if( ! wp_verify_nonce($_POST['amp_comment_form_nonce'], 'commentform_submission') ){ $comment_status = array('response' => 'Nonce not verified' ); echo wp_json_encode($comment_status); die; } $comment = wp_handle_comment_submission( wp_unslash( $_POST ) ); $text_data = 'Comment Successfully submitted'; if ($redux_builder_amp['amp-comments-Successful-message']){ $text_data = esc_html( $redux_builder_amp['amp-comments-Successful-message']); } if ( is_wp_error( $comment ) ) { $error_data = intval( $comment->get_error_data() ); if ( ! empty( $error_data ) ) { $comment_html = $comment->get_error_message(); $comment_html = str_replace("’","'",$comment_html); $comment_status = array('response' => $comment_html ); echo wp_json_encode($comment_status); die; } else { wp_die( 'Unknown error' ); } } $user = wp_get_current_user(); do_action('set_comment_cookies', $comment, $user); $comment_depth = 1; $comment_parent = $comment->comment_parent; while( $comment_parent ){ $comment_depth++; $parent_comment = get_comment( $comment_parent ); $comment_parent = $parent_comment->comment_parent; } $GLOBALS['comment'] = $comment; $GLOBALS['comment_depth'] = $comment_depth; $comment_html = $text_data; $comment_status = array('response' => $comment_html ); echo wp_json_encode($comment_status); die; } function comment_form_conversion($content){ if(strpos($content, 'id="commentform"')!==false){ $submit_url = admin_url('admin-ajax.php?action=amp_theme_ajaxcomments'); $submit_url = str_replace("http:", "", $submit_url); $comment_nonce = wp_create_nonce( 'commentform_submission' ); $mustache = '