Skip to content

Commit

Permalink
Fixed register_post_type + Revising code
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeenulislam committed Feb 21, 2016
1 parent c82fc21 commit eaf6b08
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 19 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<img src="assets/banner-1544x500.png" alt="WP AdZonia - WordPress Ad Management Plugin"/>
##WP AdZonia##
WordPress Advertisement Manager Plugin<br>
Version 1.2.1<br>
Version 1.2.2<br>
<strong>Developer:</strong> Mayeenul Islam (@mayeenulislam)<br>
[**nano**designs](http://nanodesignsbd.com)

A simplest and easiest Advertisement Manager Plugin for WordPress sites, and most astonishingly - it's in <strong>WordPress' way</strong>. You can call the advertisements into your template using a simple function: <code><?php if ( function_exists( "show_adzonia" ) ) show_adzonia( # ); ?></code>, or you can call the ad in anywhere using the shortcode: <code>[wp-adzonia id="#"]</code>, or you can use the AdZonia widget into any widget-enabled area of your site.

A new feature is added in v1.2.1 as a *beta feature* that enables any ad to show in predefined areas directly from the admin panel, without any coding. *Isn't that cool!*
A new feature is added in v1.2.2 as a *beta feature* that enables any ad to show in predefined areas directly from the admin panel, without any coding. *Isn't that cool!*

###Screenshots###
<img src="assets/screenshot-1.png" alt="WP AdZonia - List of advertisements"/>
Expand All @@ -24,15 +24,19 @@ Thanks also to Shimul Islam, Tareq Hasan, Sisir Kanti Adhikari. And thanks also
* [jQuery DateTimePicker](http://xdsoft.net/jqplugins/datetimepicker/) v2.1.1

###Change Log###
####1.2.1###
#### 1.2.2
* Fixed the `register_post_type()` as it need not to be public
* Revamped the code a bit

#### 1.2.1
* Nonce verification notifier fixed
* Reorganization of files
* Admin panel tabs for Image ad and Code ad
* No-js elements are considered and implemented
* Additional functions for more user-friendliness
* Show ad in predefined places <em style="color: red">*Beta Feature</em>

####1.2####
#### 1.2
* Completely Translation-ready
* Bengali (<em>Bangla</em>) translations
* CSS improvements
Expand All @@ -44,20 +48,20 @@ Thanks also to Shimul Islam, Tareq Hasan, Sisir Kanti Adhikari. And thanks also
* Reorganization of files
* Optional Front-end CSS

####1.1###
#### 1.1
* Incorporated AdZonia Widget
* Minor visual fixes
* Reorganized files

####1.0###
#### 1.0
* Discarded the custom table
* Initiated Custom Post Type (CPT)
* Initiated Custom Meta Fields
* Two ad types only
* Table Columns are added and organized
* Reorganized files

####0.1####
#### 0.1
* Custom Table
* Media Uploader
* Different ad types
7 changes: 6 additions & 1 deletion uninstall.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?php
/**
* Uninstallation
* @package wp-adzonia
* ----------------------------------------------------
*/
//if uninstall not called from WordPress exit
if( !defined( 'ABSPATH' ) && !defined( 'WP_UNINSTALL_PLUGIN' ) )
exit();


/**
* DELETE ALL THE THINGS, THE PLUGIN CREATED
* ----------------------------------------------------
*/

// To delete options from options table
Expand All @@ -30,7 +36,6 @@
delete_post_meta( $postid, 'wpadz_end_date' );
delete_post_meta( $postid, 'wpadz_target_url' );
delete_post_meta( $postid, 'wpadz_location' );

}

wp_reset_postdata();
36 changes: 25 additions & 11 deletions wp-adzonia.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
/**
* Plugin Name: WP AdZonia
* Plugin URI: http://nanodesignsbd.com
* Plugin URI: http://nanodesignsbd.com/
* Description: A simpler and easier advertisement manager plugin for WordPress sites, and most astonishingly - it's in WordPress way. Read the instructions (AdZonia &raquo; Settings-Instructions).
* Version: 1.2.1
* Version: 1.2.2
* Author: Mayeenul Islam (@mayeenulislam)
* Author URI: http://nanodesignsbd.com/mayeenulislam
* Author URI: http://nanodesignsbd.com/mayeenulislam/
* License: GNU General Public License v2.0
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
Expand Down Expand Up @@ -56,6 +56,7 @@ function adzonia_load_textdomain() {
* @link http://ottopress.com/2009/wordpress-settings-api-tutorial/
*
* @since 1.2.0
* ----------------------------------------------------
*/
function adzonia_settings_page() {
add_submenu_page(
Expand Down Expand Up @@ -175,6 +176,7 @@ function adzonia_options_validate( $input ) {

/**
* AdZonia Admin Styles.
* ----------------------------------------------------
*/
function adzonia_css() {
wp_enqueue_style( 'adzonia-admin-style', plugins_url('css/admin-style.css', __FILE__) );
Expand All @@ -185,6 +187,7 @@ function adzonia_css() {
/**
* AdZonia FrontEnd stylesheet.
* @see option is checked or not.
* ----------------------------------------------------
*/
if( $get_options['adzonia_css_check'] === true ) {
function adzonia_output_css() {
Expand All @@ -198,6 +201,7 @@ function adzonia_output_css() {
/**
* Enqueue necessary admin scripts.
* Load scripts only where necessary using get_currecnt_screen().
* ----------------------------------------------------
*/
function adzonia_admin_scripts() {
$screen = get_current_screen();
Expand All @@ -221,8 +225,8 @@ function adzonia_admin_scripts() {
global $post;
$image_ad = '';
$code_ad = '';
$image_ad = get_post_meta( $post->ID, 'wpadz_ad_image', TRUE );
$code_ad = get_post_meta( $post->ID, 'wpadz_ad_code', TRUE );
$image_ad = get_post_meta( $post->ID, 'wpadz_ad_image', true );
$code_ad = get_post_meta( $post->ID, 'wpadz_ad_code', true );

wp_localize_script( 'adzonia',
'adzonia', //the var key in JS
Expand All @@ -245,6 +249,7 @@ function adzonia_admin_scripts() {
* in WordPress' way.
*
* @since 1.0.0
* ----------------------------------------------------
*/
function register_cpt_adzonia() {
$labels = array(
Expand All @@ -267,13 +272,13 @@ function register_cpt_adzonia() {
'hierarchical' => false,
'description' => 'Get the advertisement information into post format',
'supports' => array( 'title', 'excerpt' ),
'public' => true,
'public' => false,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 25,
'menu_icon' => plugins_url('/assets/adzonia-icon.png', __FILE__),
'show_in_nav_menus' => false,
'publicly_queryable' => true,
'publicly_queryable' => false,
'exclude_from_search' => true,
'has_archive' => false,
'query_var' => true,
Expand All @@ -293,6 +298,7 @@ function register_cpt_adzonia() {
*
* @since 1.0.0 initiated
* @since 1.2.0 modified
* ----------------------------------------------------
*/
function adzonia_specifications_meta_box() {
add_meta_box(
Expand Down Expand Up @@ -365,8 +371,8 @@ function adzonia_specifications_specifics() {
<?php
$image_ad = '';
$code_ad = '';
$image_ad = get_post_meta( $post->ID, 'wpadz_ad_image', TRUE );
$code_ad = get_post_meta( $post->ID, 'wpadz_ad_code', TRUE );
$image_ad = get_post_meta( $post->ID, 'wpadz_ad_image', true );
$code_ad = get_post_meta( $post->ID, 'wpadz_ad_code', true );
?>

<div id="adzonia-tabs">
Expand Down Expand Up @@ -538,6 +544,7 @@ function save_adzonia_meta( $post_id ) {
* @return array Modified columns.
*
* @since 1.2.0
* ----------------------------------------------------
*/
function adzonia_set_custom_columns( $columns ) {

Expand Down Expand Up @@ -565,6 +572,7 @@ function adzonia_set_custom_columns( $columns ) {
*
* @param array $column specific post type column.
* @param integer $post_id adzonia post id.
* ----------------------------------------------------
*/
function adzonia_custom_column( $column, $post_id ) {
switch ( $column ) {
Expand Down Expand Up @@ -600,6 +608,7 @@ function adzonia_custom_column( $column, $post_id ) {
*
* @param integer $ad_id Would be the post ID.
* @return string $the_ad The complete advertisement.
* ----------------------------------------------------
*/
function get_adzonia( $ad_id ) {
$the_ad = '';
Expand Down Expand Up @@ -661,6 +670,7 @@ function get_adzonia( $ad_id ) {
* @see get_adzonia()
*
* @param integer $ad_id pass the ID of the AdZonia post.
* ----------------------------------------------------
*/
function show_adzonia( $ad_id ) {
echo get_adzonia( $ad_id );
Expand All @@ -673,6 +683,7 @@ function show_adzonia( $ad_id ) {
* @see show_adzonia()
* @param array $atts attributes that passed through shortcode.
* @return string formatted ad.
* ----------------------------------------------------
*/
function adzonia_shortcode( $atts ) {
$atts = shortcode_atts( array(
Expand All @@ -698,6 +709,7 @@ function adzonia_shortcode( $atts ) {
* Adding a widget to add ad to the widget-enabled areas easily.
*
* @since 1.2.0
* ----------------------------------------------------
*/
class adzonia_widget extends WP_Widget {
function __construct() {
Expand Down Expand Up @@ -789,6 +801,7 @@ function adzonia_load_widget() {
* Assistance from Giuseppe (aka Gmazzap, G.M.) (@gmazzap) - Italy.
* @param \WP_Query $query
* @since 1.2.1
* ----------------------------------------------------
*
* Show the advertisement into the starting of the posts or
* into the ending of the posts.
Expand All @@ -807,7 +820,7 @@ function adzonia_ad_position_executioner( \WP_Query $query ) {
'compare' => 'IN'
)
),
'nopaging' => TRUE,
'nopaging' => true,
'post_status' => 'publish'
);
$ads = get_posts( $ads_args );
Expand All @@ -818,7 +831,7 @@ function adzonia_ad_position_executioner( \WP_Query $query ) {
$after = '';
foreach( $ads as $ad ) {
$ad_content = get_adzonia( $ad->ID );
if ( get_post_meta( $ad->ID, $key, TRUE ) === 'before_content' ) {
if ( get_post_meta( $ad->ID, $key, true ) === 'before_content' ) {
$before .= $ad_content;
} else {
$after .= $ad_content;
Expand Down Expand Up @@ -865,5 +878,6 @@ function adzonia_remove_hooks() {
* are taken away from this page.
*
* @since 1.2.1
* ----------------------------------------------------
*/
require_once( 'inc/functions-additionals.php' );

0 comments on commit eaf6b08

Please sign in to comment.