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
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/accelera.../pagebuil.../inc
File: adminAjaxContents.php
<?php
[0] Fix | Delete
// Exit if accessed directly.
[1] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) exit;
[2] Fix | Delete
[3] Fix | Delete
add_action('wp_ajax_amppb_color_picker','amppb_color_picker');
[4] Fix | Delete
function amppb_color_picker(){
[5] Fix | Delete
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_pb' ) ) {
[6] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>'Request not valid'));
[7] Fix | Delete
die;
[8] Fix | Delete
}
[9] Fix | Delete
// Exit if the user does not have proper permissions
[10] Fix | Delete
if(! current_user_can( 'editor' ) ) {
[11] Fix | Delete
return ;
[12] Fix | Delete
}
[13] Fix | Delete
wp_enqueue_style( 'wp-color-picker' );
[14] Fix | Delete
echo '<input type="text" value="#bada55" class="color-field"/><script>$(\'.color-field\').wpColorPicker()</script>';
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
add_action('wp_ajax_amppb_textEditor', 'amppb_textEditor');
[18] Fix | Delete
function amppb_textEditor(){
[19] Fix | Delete
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_pb' ) ) {
[20] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages')));
[21] Fix | Delete
die;
[22] Fix | Delete
}
[23] Fix | Delete
// Exit if the user does not have proper permissions
[24] Fix | Delete
if(! current_user_can( 'editor' ) ) {
[25] Fix | Delete
return ;
[26] Fix | Delete
}
[27] Fix | Delete
echo wp_editor( '', 'My_TextAreaID_22', $settings = array( 'tinymce'=>true, 'textarea_name'=>'name77', 'wpautop' =>false, 'media_buttons' => true , 'teeny' => false, 'quicktags'=>true, ) ); exit;
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
add_action("wp_ajax_enable_amp_pagebuilder", "enable_amp_pagebuilder");
[31] Fix | Delete
function enable_amp_pagebuilder(){
[32] Fix | Delete
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_pb' ) ) {
[33] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages')));
[34] Fix | Delete
die;
[35] Fix | Delete
}
[36] Fix | Delete
// Exit if the user does not have proper permissions
[37] Fix | Delete
// check user permissions
[38] Fix | Delete
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
[39] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('User do not have access','accelerated-mobile-pages')));
[40] Fix | Delete
die;
[41] Fix | Delete
}
[42] Fix | Delete
if(isset($_POST['postId'])){
[43] Fix | Delete
$postId = intval($_POST['postId']);
[44] Fix | Delete
}else{
[45] Fix | Delete
echo wp_json_encode(array('status'=>"500", 'Message'=>esc_html__("post id not found",'accelerated-mobile-pages')));
[46] Fix | Delete
}
[47] Fix | Delete
if(isset($postId) && get_post_meta($postId,'use_ampforwp_page_builder', true)!=='yes' && current_user_can('edit_posts')){
[48] Fix | Delete
update_post_meta($postId, 'use_ampforwp_page_builder','yes');
[49] Fix | Delete
echo wp_json_encode(array('status'=>200, 'Message'=>esc_html__("Pagebuilder Started successfully",'accelerated-mobile-pages')));
[50] Fix | Delete
}else{
[51] Fix | Delete
echo wp_json_encode(array('status'=>200, 'Message'=>esc_html__("Pagebuilder Started successfully",'accelerated-mobile-pages')));
[52] Fix | Delete
}
[53] Fix | Delete
exit;
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
add_action( 'wp_ajax_amppb_export_layout_data', 'amppb_export_layout_data');
[57] Fix | Delete
function amppb_export_layout_data(){
[58] Fix | Delete
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_pb' ) ) {
[59] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages')));
[60] Fix | Delete
die;
[61] Fix | Delete
}
[62] Fix | Delete
// Exit if the user does not have proper permissions
[63] Fix | Delete
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
[64] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('User do not have access','accelerated-mobile-pages')));
[65] Fix | Delete
die;
[66] Fix | Delete
}
[67] Fix | Delete
header( 'content-type: application/json' );
[68] Fix | Delete
header( 'Content-Disposition: attachment; filename=layout-' . date( 'dmY' ) . '.json' );
[69] Fix | Delete
[70] Fix | Delete
if ( function_exists('sanitize_textarea_field') ) {
[71] Fix | Delete
$export_data = sanitize_textarea_field(wp_unslash( $_POST['export_layout_data'] ));
[72] Fix | Delete
}
[73] Fix | Delete
else{
[74] Fix | Delete
$unsan_export_data = wp_unslash( $_POST['export_layout_data'] );
[75] Fix | Delete
$export_data = implode( "\n", array_map( 'sanitize_text_field', explode( "\n", $unsan_export_data ) ));
[76] Fix | Delete
}
[77] Fix | Delete
echo $export_data; // escaped above
[78] Fix | Delete
[79] Fix | Delete
wp_die();
[80] Fix | Delete
}
[81] Fix | Delete
add_action( 'wp_ajax_amppb_save_layout_data', 'amppb_save_layout_data');
[82] Fix | Delete
function amppb_save_layout_data(){
[83] Fix | Delete
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_pb' ) ) {
[84] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages')));
[85] Fix | Delete
die;
[86] Fix | Delete
}
[87] Fix | Delete
// Exit if the user does not have proper permissions
[88] Fix | Delete
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
[89] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('User not have authority','accelerated-mobile-pages')));
[90] Fix | Delete
die;
[91] Fix | Delete
}
[92] Fix | Delete
$layoutname = sanitize_text_field($_POST['layoutname']);
[93] Fix | Delete
$layoutdata = wp_slash($_POST['layoutdata']);
[94] Fix | Delete
$postarr = array(
[95] Fix | Delete
'post_title' =>$layoutname,
[96] Fix | Delete
'post_content' =>$layoutdata,
[97] Fix | Delete
'post_author' => 1,
[98] Fix | Delete
'post_status' =>'publish',
[99] Fix | Delete
'post_type' =>'amppb_layout'
[100] Fix | Delete
);
[101] Fix | Delete
wp_insert_post( $postarr );
[102] Fix | Delete
[103] Fix | Delete
[104] Fix | Delete
$allPostLayout = array();
[105] Fix | Delete
$args = array(
[106] Fix | Delete
'posts_per_page' => 200,
[107] Fix | Delete
'orderby' => 'date',
[108] Fix | Delete
'order' => 'DESC',
[109] Fix | Delete
'post_type' => 'amppb_layout',
[110] Fix | Delete
'post_status' => 'publish'
[111] Fix | Delete
);
[112] Fix | Delete
$posts_array = get_posts( $args );
[113] Fix | Delete
if(count($posts_array)>0){
[114] Fix | Delete
foreach ($posts_array as $key => $layoutData) {
[115] Fix | Delete
$allPostLayout[] = array('post_title'=>$layoutData->post_title,
[116] Fix | Delete
'post_id'=>$layoutData->ID,
[117] Fix | Delete
'post_content'=>$layoutData->post_content,
[118] Fix | Delete
);
[119] Fix | Delete
}
[120] Fix | Delete
}
[121] Fix | Delete
echo wp_json_encode(array("status"=>200, "data"=>$allPostLayout));
[122] Fix | Delete
exit;
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
add_action( 'wp_ajax_amppb_remove_saved_layout_data', 'amppb_remove_saved_layout_data');
[126] Fix | Delete
function amppb_remove_saved_layout_data(){
[127] Fix | Delete
[128] Fix | Delete
$layoutid = intval($_POST['layoutid']);
[129] Fix | Delete
[130] Fix | Delete
// Exit if the user does not have proper permissions
[131] Fix | Delete
if ( !current_user_can( 'delete_post', $layoutid ) ) {
[132] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('User not have authority','accelerated-mobile-pages')));
[133] Fix | Delete
die;
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
check_ajax_referer( 'verify_pb', 'verify_nonce' );
[137] Fix | Delete
$users = wp_get_current_user();
[138] Fix | Delete
$roles = $users->roles;
[139] Fix | Delete
if(in_array("administrator", $roles) || in_array("editor", $roles)||in_array("author", $roles)|| in_array("contributor", $roles)){
[140] Fix | Delete
$is_delete = wp_delete_post($layoutid);
[141] Fix | Delete
$allPostLayout = array();
[142] Fix | Delete
$args = array(
[143] Fix | Delete
'posts_per_page' => 200,
[144] Fix | Delete
'orderby' => 'date',
[145] Fix | Delete
'order' => 'DESC',
[146] Fix | Delete
'post_type' => 'amppb_layout',
[147] Fix | Delete
'post_status' => 'publish'
[148] Fix | Delete
);
[149] Fix | Delete
$posts_array = get_posts( $args );
[150] Fix | Delete
if(count($posts_array)>0){
[151] Fix | Delete
foreach ($posts_array as $key => $layoutData) {
[152] Fix | Delete
$allPostLayout[] = array('post_title'=>$layoutData->post_title,
[153] Fix | Delete
'post_id'=>$layoutData->ID,
[154] Fix | Delete
'post_content'=>$layoutData->post_content,
[155] Fix | Delete
);
[156] Fix | Delete
}
[157] Fix | Delete
}
[158] Fix | Delete
if ( $is_delete ) {
[159] Fix | Delete
echo wp_json_encode(array("status"=>200,"data"=>$allPostLayout));
[160] Fix | Delete
exit;
[161] Fix | Delete
}
[162] Fix | Delete
else{
[163] Fix | Delete
echo wp_json_encode(array("status"=>404,"data"=>$allPostLayout));
[164] Fix | Delete
exit;
[165] Fix | Delete
}
[166] Fix | Delete
}else{
[167] Fix | Delete
echo wp_json_encode(array("status"=>403,"data"=>array()));
[168] Fix | Delete
exit;
[169] Fix | Delete
}
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
// Ajax action to refresh the user image
[173] Fix | Delete
add_action( 'wp_ajax_ampforwp_get_image', 'ampforwp_get_image');
[174] Fix | Delete
function ampforwp_get_image() {
[175] Fix | Delete
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_pb' ) ) {
[176] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages')
[177] Fix | Delete
));
[178] Fix | Delete
die;
[179] Fix | Delete
}
[180] Fix | Delete
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
[181] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('User not have authority','accelerated-mobile-pages')
[182] Fix | Delete
));
[183] Fix | Delete
die;
[184] Fix | Delete
}
[185] Fix | Delete
$get_id = intval($_GET['id']);
[186] Fix | Delete
if(isset($get_id)){
[187] Fix | Delete
if(strpos($get_id,",") !== false){
[188] Fix | Delete
$get_ids = explode(",", $get_id);
[189] Fix | Delete
[190] Fix | Delete
if(count($get_ids)>0){
[191] Fix | Delete
foreach($get_ids as $id){
[192] Fix | Delete
$image = wp_get_attachment_image( $id, 'full', false, array( 'id' => 'ampforwp-preview-image' ) );
[193] Fix | Delete
$image_src = wp_get_attachment_image_src($id, 'full', false);
[194] Fix | Delete
$data[] = array(
[195] Fix | Delete
'image' => $image,
[196] Fix | Delete
'detail' => $image_src
[197] Fix | Delete
);
[198] Fix | Delete
[199] Fix | Delete
}
[200] Fix | Delete
}
[201] Fix | Delete
}else{
[202] Fix | Delete
$id = intval($_GET['id']);
[203] Fix | Delete
$image = wp_get_attachment_image( $id, 'full', false, array( 'id' => 'ampforwp-preview-image' ) );
[204] Fix | Delete
$image_src = ampforwp_get_attachment_id($id,'thumbnail');
[205] Fix | Delete
$image_src_full = ampforwp_get_attachment_id($id,'full');
[206] Fix | Delete
$svg = pathinfo($image_src_full[0], PATHINFO_EXTENSION) == 'svg' ? true : false;
[207] Fix | Delete
if ( $svg ) {
[208] Fix | Delete
$image_src_full[1] = 50;
[209] Fix | Delete
$image_src_full[2] = 50;
[210] Fix | Delete
}
[211] Fix | Delete
$data = array(
[212] Fix | Delete
'image' => $image,
[213] Fix | Delete
'detail' => $image_src,
[214] Fix | Delete
'front_image'=> $image_src_full,
[215] Fix | Delete
);
[216] Fix | Delete
}
[217] Fix | Delete
wp_send_json_success( $data );
[218] Fix | Delete
exit;
[219] Fix | Delete
} else {
[220] Fix | Delete
wp_send_json_error();
[221] Fix | Delete
exit;
[222] Fix | Delete
}
[223] Fix | Delete
}
[224] Fix | Delete
[225] Fix | Delete
[226] Fix | Delete
add_action( 'wp_ajax_ampforwp_icons_list_format', 'ampforwp_icons_list_format');
[227] Fix | Delete
function ampforwp_icons_list_format(){
[228] Fix | Delete
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_pb' ) ) {
[229] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages')));
[230] Fix | Delete
die;
[231] Fix | Delete
}
[232] Fix | Delete
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
[233] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('User not have authority','accelerated-mobile-pages')));
[234] Fix | Delete
die;
[235] Fix | Delete
}
[236] Fix | Delete
$amp_icons_css_array = include AMPFORWP_PLUGIN_DIR .'includes/icons/amp-icons.php';
[237] Fix | Delete
[238] Fix | Delete
foreach ($amp_icons_css_array as $key=>$value ) {
[239] Fix | Delete
$amp_icons_list[] = array('name'=>$key);
[240] Fix | Delete
}
[241] Fix | Delete
echo wp_json_encode(array('success'=>true,'data'=>$amp_icons_list));
[242] Fix | Delete
exit;
[243] Fix | Delete
}
[244] Fix | Delete
add_action( 'wp_ajax_ampforwp_pb_taxonomy', 'ampforwp_pb_taxonomy');
[245] Fix | Delete
function ampforwp_pb_taxonomy(){
[246] Fix | Delete
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_pb' ) ) {
[247] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages')));
[248] Fix | Delete
die;
[249] Fix | Delete
}
[250] Fix | Delete
$taxs = array();
[251] Fix | Delete
$post = '';
[252] Fix | Delete
$post = sanitize_text_field($_POST['selected_val']);
[253] Fix | Delete
$taxs = get_object_taxonomies( $post );
[254] Fix | Delete
$return = array();
[255] Fix | Delete
if(!empty($taxs)){
[256] Fix | Delete
foreach ($taxs as $taxonomy) {
[257] Fix | Delete
$taxonomies = get_taxonomy( $taxonomy );
[258] Fix | Delete
$return[esc_attr($taxonomies->name)] = esc_html($taxonomies->labels->singular_name);
[259] Fix | Delete
}
[260] Fix | Delete
}
[261] Fix | Delete
$return['recent_option']= 'Recent Posts';
[262] Fix | Delete
echo wp_json_encode(array('success'=>true,'data'=>$return));
[263] Fix | Delete
exit;
[264] Fix | Delete
[265] Fix | Delete
}
[266] Fix | Delete
add_action( 'wp_ajax_ampforwp_pb_cats', 'ampforwp_pb_cats');
[267] Fix | Delete
function ampforwp_pb_cats(){
[268] Fix | Delete
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_pb' ) ) {
[269] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages')));
[270] Fix | Delete
die;
[271] Fix | Delete
}
[272] Fix | Delete
$cats = array();
[273] Fix | Delete
$taxonomy = '';
[274] Fix | Delete
$taxonomy = sanitize_text_field($_POST['selected_val']);
[275] Fix | Delete
$terms = get_terms( $taxonomy, array(
[276] Fix | Delete
'orderby' => 'name',
[277] Fix | Delete
'order' => 'ASC',
[278] Fix | Delete
'number' => 500
[279] Fix | Delete
) );
[280] Fix | Delete
$return = array();
[281] Fix | Delete
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
[282] Fix | Delete
foreach ($terms as $key => $value) {
[283] Fix | Delete
$return[$value->term_id] = $value->name;
[284] Fix | Delete
}
[285] Fix | Delete
}
[286] Fix | Delete
$return['recent_option']= 'Recent Posts';
[287] Fix | Delete
echo wp_json_encode(array('success'=>true,'data'=>$return));
[288] Fix | Delete
exit;
[289] Fix | Delete
}
[290] Fix | Delete
[291] Fix | Delete
add_action( 'wp_ajax_ampforwp_dynaminc_css', 'ampforwp_dynaminc_css' );
[292] Fix | Delete
add_action( 'wp_ajax_nopriv_ampforwp_dynaminc_css', 'ampforwp_dynaminc_css' );
[293] Fix | Delete
[294] Fix | Delete
function ampforwp_dynaminc_css() {
[295] Fix | Delete
if(!isset($_REQUEST['verify_nonce']) || !wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_pb' ) ) {
[296] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages')));
[297] Fix | Delete
die;
[298] Fix | Delete
}
[299] Fix | Delete
if(!is_admin()){
[300] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('user not valid','accelerated-mobile-pages')));
[301] Fix | Delete
die;
[302] Fix | Delete
}
[303] Fix | Delete
$amp_icons_css_array = include AMPFORWP_PLUGIN_DIR .'includes/icons/amp-icons.php';
[304] Fix | Delete
header("Content-type: text/css; charset: UTF-8");
[305] Fix | Delete
foreach ($amp_icons_css_array as $key=>$value ) {
[306] Fix | Delete
echo $value;
[307] Fix | Delete
}
[308] Fix | Delete
exit;
[309] Fix | Delete
}
[310] Fix | Delete
[311] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function