array(
'name' => __( 'Adverts' ,$this->plugin),
'singular_name' => __( 'Advert',$this->plugin),
'search_items' => __( 'Search Adverts' ,$this->plugin),
'all_items' => __( 'All Adverts' ,$this->plugin),
'parent_item' => __( 'Parent Advert',$this->plugin),
'parent_item_colon' => __( 'Parent Advert:',$this->plugin ),
'edit_item' => __( 'Edit Advert',$this->plugin ),
'update_item' => __( 'Update Advert' ,$this->plugin),
'add_new_item' => __( 'Add New Advert' ,$this->plugin ),
'add_new' => __( 'New Advert', $this->plugin ),
'new_item_name' => __( 'New Advert Name',$this->plugin ),
'new_item' => __( 'New Advert', $this->plugin ),
'menu_name' => __( 'Adverts',$this->plugin ) ,
),
'description' => 'Adding and editing my Adverts',
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-external',
'rewrite' => array('slug' => 'webd_adverts'),
'supports' => array( 'title', 'thumbnail' ),
'show_in_rest' => true,
'rest_base' => 'webd_adverts',
'rest_controller_class' => 'WP_REST_Posts_Controller',
'capability_type' => 'page',
'hierarchical' => true,
'public' => false, // it's not public, it shouldn't have it's own permalink, and so on
'publicly_queryable' => true, // you should be able to query it
'show_ui' => true, // you should be able to edit it in wp-admin
'exclude_from_search' => true, // you should exclude it from search results
'show_in_nav_menus' => false, // you shouldn't be able to add it to menus
'has_archive' => false, // it shouldn't have archive page
'rewrite' => false, // it shouldn't have rewrite rules
)
);
}
public function createTables(){
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
$table_name = $wpdb->prefix . "adverts";
$table_name2 = $wpdb->prefix . "advert_clicks";
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
post_id mediumint(9) NOT NULL,
clicks mediumint(9) NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
$sql2 = "CREATE TABLE $table_name2 (
id mediumint(9) NOT NULL AUTO_INCREMENT,
post_id mediumint(9) NOT NULL,
clicks mediumint(9) NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
dbDelta( $sql2 );
}
public function adminHeader(){ ?>
slug.'.png', __FILE__ ); ?>' style='width:100%' />
".$this->name."";
}
public function proModal(){ ?>
×
slug.'-pro.png', __FILE__ ); ?>' style='width:100%' />
Go PRO and get more important features!
Get a widget to display your content
Widget can be displayed as popup!
Categorize your adverts & display per category
Set expire date for adverts - display those that haven't expired
Set Order of adverts for displaying
Display adverts in a slideshow - from the shortcode or the widget
GET IT HERE
adminTabs();
?>
VIDEO
processSettings(); ?>
slug.'-pro.png', __FILE__ ); ?>' style='width:100%' />
Go PRO and get more important features!
Get a widget to display your content
Widget can be displayed as popup!
Categorize your adverts & display per category
Set expire date for adverts - display those that haven't expired
Set Order of adverts for displaying
Display adverts in a slideshow - from the shortcode or the widget
GET IT HERE
tab = array( 'general' => 'General','info' => 'Guide');
if($_GET['tab'] ){
$this->activeTab = $_GET['tab'] ;
}else $this->activeTab = 'general';
echo '';
foreach( $this->tab as $tab => $name ){
$class = ( $tab == $this->activeTab ) ? ' nav-tab-active' : '';
echo "".$name." ";
}?>
Video
GO PRO
';
}
public function adminFooter(){ ?>
' alt='Get more plugins by webdeveloping.gr' title='Get more plugins by webdeveloping.gr' />
GET PRO VERSION
plugin.$this->orderDisplay]) ){
?>plugin.$this->orderDisplay] ); ?> plugin.$this->orderDisplay)) ){ ?>
plugin.$this->orderDisplay)) ; ?>
Select...
ID
title
name
date
rand
plugin.$this->columns]) ){
?>plugin.$this->columns] ); ?> plugin.$this->columns)) ){ ?>
plugin.$this->columns)) ; ?>
Select...
column1
columns2
columns3
columns4
columns5
columns6
plugin.$this->tabName);
}
public function processSettings(){
if($_SERVER['REQUEST_METHOD'] == 'POST' && current_user_can('administrator') ){
check_admin_referer( $this->plugin );
check_ajax_referer($this->plugin);
if($_REQUEST[$this->plugin.$this->orderDisplay]){
update_option($this->plugin.$this->orderDisplay,sanitize_text_field($_REQUEST[$this->plugin.$this->orderDisplay]));
echo " ".sanitize_text_field($_REQUEST[$this->plugin.$this->orderDisplay])." was added.
";
}
if($_REQUEST[$this->plugin.$this->perPage]){
update_option($this->plugin.$this->perPage,sanitize_text_field($_REQUEST[$this->plugin.$this->perPage]));
echo "".sanitize_text_field($_REQUEST[$this->plugin.$this->perPage])." was added.
";
}
if($_REQUEST[$this->plugin.$this->columns]){
update_option($this->plugin.$this->columns,sanitize_text_field($_REQUEST[$this->plugin.$this->columns]));
echo "".sanitize_text_field($_REQUEST[$this->plugin.$this->columns])." was added.
";
}
}
}
public function metaBox($post){
add_meta_box("advertDescription", __('Description',$this->plugin), array($this,"descCreate" ) , "webd_adverts", "normal", "high");
add_meta_box("advertUrl", __('Info',$this->plugin), array($this,"urlCreate" ) , "webd_adverts", "normal", "high");
}
public function descCreate($post){
$desci = get_post_custom($post->ID);
$desc = $desci[$this->plugin.'desc'][0];
wp_editor( htmlspecialchars_decode(esc_textarea($desc)) ,$this->plugin.'desc' , $settings = array('textarea_name'=>$this->plugin.'desc' ) );
}
public function urlCreate($post){
$custom = get_post_custom($post->ID);
$url = $custom[$this->plugin."url"][0];
?> plugin."expdate"][0];
?>
plugin.'desc']) || $_POST[$this->plugin.'desc']=='') {
$desc=htmlspecialchars(sanitize_textarea_field($_POST[$this->plugin.'desc']) );
update_post_meta($post->ID, $this->plugin.'desc', $desc);
}
if (!empty($_POST[$this->plugin.'url']) || $_POST[$this->plugin.'url']=='') {
$url=htmlspecialchars(sanitize_text_field($_POST[$this->plugin.'url']) );
update_post_meta($post->ID, $this->plugin.'url', $url);
}
}
public function advert_click_counter() {
if ( isset( $_POST['nonce'] ) && isset( $_POST['post_id'] ) && wp_verify_nonce( $_POST['nonce'], 'advert_click_counter' ) ) {
global $wpdb;
$table= $wpdb->prefix ."adverts";
$table2= $wpdb->prefix ."advert_clicks";
$store_arr["post_id"]= sanitize_text_field($_POST['post_id']);
$store_arr["clicks"]= 1;
$store_arr["date"] = current_time('mysql', false);
$store_arr2["post_id"] =sanitize_text_field($_POST['post_id']);
$store_arr2["clicks"]= 1;
$wpdb->insert( $table, $store_arr);
$post_id = $wpdb->get_row( "SELECT * FROM $table2 WHERE post_id = '".$_POST['post_id']."' " );
if($post_id->clicks > 0) {
$clicks = $post_id->clicks + 1;
$post_id = $_POST['post_id'];
$wpdb->query( $wpdb->prepare("UPDATE $table2
SET clicks = %s
WHERE post_id = %s",$clicks, $post_id)
);
}else{
$wpdb->insert( $table2, $store_arr2);
}
}else print "Problem!";
exit();
}
public function advertClickEvent() {
global $post;
//if( isset( $post->ID ) ) {
?>
prefix .'adverts';
$wpdb->delete( $table, array( 'post_id' => $postid ) );
$table2 = $wpdb->prefix .'advert_clicks';
$wpdb->delete( $table2, array( 'post_id' => $postid ) );
}
public function deleteAdStats(){
if(isset($_POST['deleteAdStats']) ){
global $wpdb;
$table = $wpdb->prefix .'adverts';
$table2 = $wpdb->prefix .'advert_clicks';
$delete = $wpdb->query("TRUNCATE TABLE $table");
$delete2 = $wpdb->query("TRUNCATE TABLE $table2");
}
}
public function displayAds($atts){
ob_start();
if(!empty(get_option($this->plugin.$this->orderDisplay) )){
$orderDisplay = esc_attr(get_option($this->plugin.$this->orderDisplay));
}else $orderDisplay = 'rand';
if(!empty(get_option($this->plugin.$this->perPage) )){
$perPage = esc_attr(get_option($this->plugin.$this->perPage));
}else $perPage = 'rand';
if(!empty(get_option($this->plugin.$this->columns) )){
$columns = esc_attr(get_option($this->plugin.$this->columns));
}else $columns = '';
$atts = shortcode_atts(
array(
'orderby' => $orderDisplay,
'order' => 'ASC',
'posts_per_page' => $perPage,
'column' => $columns,
'title' => '',
'image_size' => '',
), $atts, 'displayAds' );
global $post;
$post_type = explode(",", $atts['type']);
$posts = get_posts(array(
'post_type' => 'webd_adverts',
'orderby' => sanitize_text_field($atts['orderby']),
'order' => sanitize_text_field($atts['order']),
'posts_per_page' => (int)$atts['posts_per_page'],
'title' => sanitize_text_field($atts['title']),
));
?>
prefix ."adverts";
$table_name2 = $wpdb->prefix ."advert_clicks";
$clicks = $wpdb->get_results( "SELECT * FROM $table_name2 " ); ?>
num_rows > 0) { ?>
".get_the_title( $row->post_id )." Clicks: ". esc_attr($row->clicks)." ";
print "";
$ads = $wpdb->get_results( "SELECT COUNT(*) as c, DATE_FORMAT(date , '%M %Y') as d,date FROM $table_name WHERE post_id ='".$row->post_id."' GROUP BY DATE_FORMAT(date , '%M %Y') ORDER BY date DESC" );
foreach ($ads as $row1){ ?>
d) ." : " .esc_attr($row1->c)."
";
?>
get_results( "SELECT DATE_FORMAT(date , '%D %M %Y - %H:%i:%s') as d FROM $table_name WHERE post_id ='".$row->post_id."' ORDER BY date DESC " );
print "
";
foreach ($adsl as $row){
print esc_attr($row->d)." ";
}
print "
";
?>
";
}else print "".__('No statistics found...',$this->plugin)."
" ?>