*/
class Applyonline_Admin {
/**
* The ID of this plugin.
*
* @since 1.0.0
* @access private
* @var string $plugin_name The ID of this plugin.
*/
private $plugin_name;
/**
* The version of this plugin.
*
* @since 1.0.0
* @access private
* @var string $version The current version of this plugin.
*/
private $version;
/**
* Initialize the class and set its properties.
*
* @since 1.0.0
* @param string $plugin_name The name of this plugin.
* @param string $version The version of this plugin.
*/
public function __construct( $plugin_name, $version ) {
$this->plugin_name = $plugin_name;
$this->version = $version;
add_action( 'init', array( $this, 'register_aol_post_types' ) );
add_shortcode( 'aol', array($this, 'shortcode_generator') );
//Depricated. will be removed on 1st January 2016.
add_shortcode( 'aol_ads', array($this, 'shortcode_generator') );
// Hook - Applicant Listing - Column Name
add_filter( 'manage_edit-aol_application_columns', array ( $this, 'applicants_list_columns' ) );
// Hook - Applicant Listing - Column Value
add_action( 'manage_aol_application_posts_custom_column', array ( $this, 'applicants_list_columns_value' ), 10, 2 );
add_filter('post_row_actions',array($this, 'application_row_actions'), 10, 2);
// Add Application data to the Application editor.
add_action ( 'edit_form_after_title', array ( $this, 'aol_application_post_editor' ) );
//Admin Panel Docs
add_action('admin_menu', array($this, 'docs'));
new MetaBoxes();
new AjaxHandler();
}
/**
* Register the stylesheets for the admin area.
*
* @since 1.0.0
*/
public function enqueue_styles() {
/**
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Applyonline_Loader as all of the hooks are defined
* in that particular class.
*
* The Applyonline_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/applyonline-admin.css', array(), $this->version, 'all' );
}
/**
* Register the JavaScript for the admin area.
*
* @since 1.0.0
*/
public function enqueue_scripts() {
/**
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Applyonline_Loader as all of the hooks are defined
* in that particular class.
*
* The Applyonline_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/applyonline-admin.js', array( 'jquery' ), $this->version, false );
}
function register_aol_post_types(){
/*Register Main Post Type*/
$labels=array(
'add_new' => 'Create an Ad',
'add_new_item' => 'New Ad',
'edit_item' => 'Edit Ad',
'all_items' => 'All Ads',
'menu_name' => 'Apply Online'
);
$args=array(
'label' => __( 'All Ads', 'applyonline' ),
'labels'=> $labels,
'public'=> true,
'show_in_nav_menus' => false,
'menu_icon' => 'dashicons-admin-site',
'description' => __( 'Ad Posting' ),
'supports' => array('title', 'editor'),
'rewrite' => array('slug'=>'ads'),
);
register_post_type('aol_ad',$args);
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
'name' => _x( 'Ad Categories', 'taxonomy singular name', 'applyOnline' ),
'singular_name' => _x( 'Ad Category','taxonomy singular name', 'applyOnline' ),
'search_items' => __( 'Search Categories' ),
'all_items' => __( 'All Categories' ),
'parent_item' => __( 'Parent Category' ),
'parent_item_colon' => __( 'Parent Category:' ),
'edit_item' => __( 'Edit Category' ),
'update_item' => __( 'Update Category' ),
'add_new_item' => __( 'Add New Category' ),
'new_item_name' => __( 'New Category Name' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'adcat' ),
);
register_taxonomy( 'aol_ad_category', array( 'aol_ad' ), $args );
/*Register Applications Post Type*/
$lables= array(
'edit_item'=>'Application'
);
$args=array(
'label' => __( 'Applications', 'applyonline' ),
'labels' => $lables,
'public' => true,
'show_in_nav_menus' => false,
'exclude_from_search'=> true,
'publicly_queryable' => false,
'map_meta_cap' => true,
'show_in_menu' => 'edit.php?post_type=aol_ad',
'description' => __( 'List of Applications with their resume', 'applyonline' ),
'supports' => array('editor'),
'capabilities' => array(
'create_posts' => false,
)
);
register_post_type('aol_application',$args);
}
/**
* Shortcode Generator
* @param type $atts
* @return type
*/
function shortcode_generator( $atts ) {
$a = shortcode_atts( array(
'categories' => NULL,
'ads' => NULL,
'excerpt' => 'yes',
'per_page' => '-1'
), $atts );
$args=array(
'posts_per_page'=> $a['per_page'],
'post_type' =>'aol_ad',
);
if(isset($a['categories'])) {
$args['tax_query'] = array(
array('taxonomy' => 'aol_ad_category', 'terms' => explode(',',$atts['categories']))
);
}
if(isset($a['ads'])) {
$args['post__in'] = explode(',',$atts['ads']);
}
query_posts( $args );
function custom_excerpt_more( $more ) {
return '....';
}
add_filter( 'excerpt_more', 'custom_excerpt_more' );
ob_start();
echo '
[aol] shortocode bug fixed (was not working in few cases in previous version).
Shortcode updated.
categories attribute added to show ads from particular category/categories only. i.e. categories="1,2,3".
ads attribute updated, now shows particular ads only with this attribute. i.e. ads="1,2,3".
new shortcode is [aol categories="1,2,3" ads="1,2,3" excerpt="yes"]
All attributes are optional. Use only when needed.
Bug fixed for Resume/CV attachment with application.
FAQs
How to create an ad?
In your WordPress admin panel, go to "Apply Online" menu and add a new ad listing.
How to show ad listings on the front-end?
Add [aol] shortcode in an existing page or add a new page and write shortcode anywhere in the page editor. Now click on VIEW to see all of your ads on front-end.
Can I show few adds on front-end?
Yes, you can show any number of ads on your website by using shortcode with "ads" attribute. Ad ids must be separated with commas i.e. [aol ads="1,2,3"].
Can I show ads from particular category only?
Yes, you can show ads from any category / categories using "categories" attribute. Categories' ids must be separated with commas i.e. [aol categories="1,2,3"].
Can I show ads without excerpt/summary?
Yes, use shortcode with "excerpt" attribute i.e. [aol excerpt="no"]
What attributes can i use in the shortcode?
Default shortcode with all attributes is [aol categories="1,2,3" ads="1,2,3" excerpt="no"]. Use only required attributes.
How can i get the id of a category or ad?
In admin panel, move your mouse pointer on an item in categories or ads table. Now you can view item ID in the info bar of the browser.