postmeta where $wpdb->postmeta.meta_key='wp_automatic_camp' and $wpdb->postmeta.meta_value=$id"; $rows=$wpdb->get_results($query); $i=0; foreach ($rows as $row){ $pid = $row->post_id; $ret = wp_delete_post($pid , true ); $i++; } delete_post_meta($id, 'wp_automatic_duplicate_cache'); echo $i.' posts deleted'; }elseif( $key == 'forgetExcluded' ){ delete_post_meta($id,'_execluded_links'); echo 'Excluded links forgotten.'; }elseif( $key == 'forgetPosted' ){ global $wpdb; $query="delete from {$wpdb->prefix}automatic_links where link_keyword=$id"; $wpdb->query($query); delete_post_meta($id, 'wp_automatic_duplicate_cache'); echo 'Posts urls forgotten, This feature is only helpfull if you have activated the option to never post same url again as it deletes the urls from its memory.'; }elseif( $key == 'reactivateAll' ){ global $wpdb; $query = "SELECT * FROM {$wpdb->prefix}automatic_camps where camp_id =$id"; $camps = $wpdb->get_results ( $query ); if(isset($camps[0])){ $keywords = explode(',' , $camps[0]->camp_keywords); } foreach($keywords as $keyword){ delete_post_meta( $id , '_' . md5(wp_automatic_trim($keyword)) ); } echo 'Reactivated'; } die(); } add_action( 'wp_ajax_wp_automatic_yt_playlists', 'wp_automatic_yt_playlists_callback' ); function wp_automatic_yt_playlists_callback() { //verify nonce if ( ! wp_verify_nonce( $_POST['nonce'], 'wp_automatic_nonce' ) ) { die( 'Security check' ); } //role check admin if(! current_user_can('administrator')){ die('Security check'); } //return ini $ret= array(); $ret['status'] = 'error'; $ret['message'] = ''; $ret['data'] = ''; //user channerl $user = wp_automatic_trim($_POST['user']); //if empty user if(wp_automatic_trim($user) == ''){ $ret['message'] = 'empty user'; print_r(json_encode($ret)); die(); } $start=1; $playlists=array(); $playlist = array(); $firstPlaylist['id'] = ''; $firstPlaylist['title'] = '--CHOOSE A LIST--'; $playlists[] = $firstPlaylist; for($i = 0;$i<5;$i++){ //get user playlists feed page like: https://gdata.youtube.com/feeds/api/users/NAHBTV/playlists $wp_automatic_yt_tocken = wp_automatic_single_item('wp_automatic_yt_tocken'); //$url="https://www.googleapis.com/youtube/v3/search?part=snippet&type=playlist&key=".wp_automatic_trim($wp_automatic_yt_tocken)."&maxResults=50&channelId=".wp_automatic_trim($user); $url="https://www.googleapis.com/youtube/v3/playlists?part=snippet&key=".wp_automatic_trim($wp_automatic_yt_tocken)."&maxResults=50&channelId=".wp_automatic_trim($user); //page token if(isset($json_result->nextPageToken)){ $url.= '&pageToken='.$json_result->nextPageToken; } //curl ini $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT,20); curl_setopt($ch, CURLOPT_REFERER, 'http://www.bing.com/'); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36'); curl_setopt($ch, CURLOPT_MAXREDIRS, 5); // Good leeway for redirections. @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // Many login forms redirect at least once. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //curl get $x='error'; curl_setopt($ch, CURLOPT_HTTPGET, 1); curl_setopt($ch, CURLOPT_URL, wp_automatic_trim($url)); $exec=curl_exec($ch); $x=curl_error($ch); //if no response back if(wp_automatic_trim($exec) == ''){ $ret['message'] = 'Empty response from YT '.$x; print_r(json_encode($ret)); die(); } //extracting $json_result = json_decode($exec); $items = $json_result->items; $singlePlayCount = 0; foreach ($items as $entry){ $playlist_id = $entry->id; $playlist['id'] = $playlist_id; $playlist['title'] =$entry->snippet->title ; $playlists[] = $playlist; $singlePlayCount++; } if( $singlePlayCount < 50 ){ break; } $start = $start +50; } $ret['status'] = 'success'; $ret['data'] = $playlists; //save list update_post_meta($_POST['pid'], 'wp_automatic_yt_playlists', $playlists); print_r(json_encode($ret)); die(); die(); } // DailyMotion Playlists add_action( 'wp_ajax_wp_automatic_dm_playlists', 'wp_automatic_dm_playlists_callback' ); function wp_automatic_dm_playlists_callback() { //verify nonce if ( ! wp_verify_nonce( $_POST['nonce'], 'wp_automatic_nonce' ) ) { die( 'Security check' ); } //role check admin if(! current_user_can('administrator')){ die('Security check'); } //return ini $ret= array(); $ret['status'] = 'error'; $ret['message'] = ''; $ret['data'] = ''; //user channel $user = wp_automatic_trim($_POST['user']); //if empty user if(wp_automatic_trim($user) == ''){ $ret['message'] = 'empty user'; print_r(json_encode($ret)); die(); } $start=1; $playlists=array(); $playlist = array(); $firstPlaylist['id'] = ''; $firstPlaylist['title'] = '--CHOOSE A LIST--'; $playlists[] = $firstPlaylist; //https://api.dailymotion.com/playlists?owner=Dakar&limit=100 $url="https://api.dailymotion.com/playlists?limit=100&owner=".wp_automatic_trim($user); //curl ini $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT,20); curl_setopt($ch, CURLOPT_REFERER, 'http://www.bing.com/'); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8'); curl_setopt($ch, CURLOPT_MAXREDIRS, 5); // Good leeway for redirections. @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // Many login forms redirect at least once. //curl get $x='error'; curl_setopt($ch, CURLOPT_HTTPGET, 1); curl_setopt($ch, CURLOPT_URL, wp_automatic_trim($url)); $exec=curl_exec($ch); $x=curl_error($ch); //if no response back if(wp_automatic_trim($exec) == ''){ $ret['message'] = 'Empty response from YT '.$x; print_r(json_encode($ret)); die(); } //extracting $json_result = json_decode($exec); $items = $json_result->list; foreach ($items as $entry){ $playlist_id = $entry->id; $playlist['id'] = $playlist_id; $playlist['title'] =$entry->name ; $playlists[] = $playlist; } $ret['status'] = 'success'; $ret['data'] = $playlists; //save list update_post_meta($_POST['pid'], 'wp_automatic_dm_playlists', $playlists); print_r(json_encode($ret)); die(); } add_action( 'wp_ajax_wp_automatic_more_posted_posts', 'more_posted_posts_callback' ); function more_posted_posts_callback() { //verify nonce if ( ! wp_verify_nonce( $_POST['nonce'], 'wp_automatic_nonce' ) ) { die( 'Security check' ); } //role check admin if(! current_user_can('administrator')){ die('Security check'); } //global global $wpdb; $prefix=$wpdb->prefix; //from data $camp = $_POST['camp']; $page = $_POST['page']; if(! is_numeric($_POST['camp']) || ! current_user_can('administrator') ){ echo 'Not valid request'; die(); } //get rows $query="SELECT * FROM {$prefix}automatic_log where action='Posted:$camp' order by id DESC limit $page , 10"; $rows=$wpdb->get_results($query); foreach ($rows as $row){ echo '