Class 11

[php]

<?php if ( ! defined( ‘ABSPATH’ ) ) { die; } // Cannot access pages directly.
/**
*
* CSFramework Metabox Config
*
* @since 1.0
* @version 1.0
*
*/

function seo_post_meta_function(){

$options = array();

$options[] = array(
‘id’ => ‘_seo_meta_options’,
‘title’ => ‘Post Options’,
‘post_type’ => ‘page’, // or post or CPT or array( ‘page’, ‘post’ )
‘context’ => ‘normal’,
‘priority’ => ‘high’,
‘sections’ => array(

// begin section
array(
‘name’ => ‘seoPostMeta’,
‘title’ => ‘Post Options’,
‘icon’ => ‘fa fa-wifi’,
‘fields’ => array(

// a field
array(
‘id’ => ‘postTitle’,
‘type’ => ‘switcher’,
‘title’ => ‘Enable Title?’,
),
array(
‘id’ => ‘postContent’,
‘type’ => ‘switcher’,
‘title’ => ‘Enable Content?’,
),

),
),
)
);

return $options;
}
add_filter(‘cs_metabox_options’, ‘seo_post_meta_function’);

[/php]

Class 10

[php]

<?php

/*
Plugin Name: Intern Shortcode
Plugin URI: http://totthoprojukti.com
Author: Md Hasan Fardous
Author URI: http://hasanfardous.me
Description: This is for practice purpose only.
Version: 1.0
*/
// Exit if access directly

if(! defined(‘ABSPATH’)){
exit;
}
// define
define( ‘SEO_ACC_URL’, WP_PLUGIN_URL . ‘/’ . plugin_basename ( dirname (__FILE__)) . ‘/’ );
define( ‘SEO_ACC_PATH’, plugin_dir_path (__FILE__) );
// print shortcodes in widget
add_filter(‘widget_text’, ‘do_shortcode’);
// loading vc-addons
require_once(SEO_ACC_PATH. ‘vc-addons/vc-blocks-load.php’);
// loading vc-addons
require_once(SEO_ACC_PATH. ‘vc-addons/vc-blocks-load.php’);

// theme shortcodes
require_once(SEO_ACC_PATH. ‘theme-shortcodes/slides-shortcode.php’);

// shortcodes depended on visual composer
include_once(ABSPATH . ‘wp-admin/includes/plugin.php’);
if(is_plugin_active(‘js_composer/js_composer.php’)){
require_once(SEO_ACC_PATH. ‘theme-shortcodes/staff-shortcode.php’);
}

// registering seo toolkit files
function seo_toolkit_files(){
wp_enqueue_style(‘owl-carousel’, plugin_dir_url(__FILE__) . ‘asset/css/owl.carousel.css’);
wp_enqueue_script(‘owl-carousel’, plugin_dir_url(__FILE__) . ‘asset/css/owl.carousel.min.js’, array(‘jquery’), 20120206, true);
}
add_action(‘wp_enqueue_scripts’, ‘seo_toolkit_files’);

&nbsp;

&nbsp;

//vc blocks load file

&nbsp;

if(!defined(‘ABSPATH’)) die(‘-1’);

//class started
class seoVCExtendAddonClass{
function __construct(){
//we safely ingrate with vc with this hook
add_action(‘init’, array($this, ‘seoIntegrateWithVC’));
}

public function seoIntegrateWithVC(){
//check if visual composer is not installed
if(! defined(‘WPB_VC_VERSION’)){
add_action(‘admin_notices’, array($this, ‘seoShowVCVersionNotice’));
return;
}

//visual composer addons
include SEO_ACC_PATH . ‘/vc-addons/vc-slides.php’;
}

//show visual composer version
public function seoShowVCVersionNotice(){
$theme_data = wp_get_theme();
echo ‘
<div class="notice notice-warning">
<p>’.sprintf(‘<strong>%s</strong> recommends <strong><a href="’.site_url().’/wp-admin/themes.php?page=tgmpa-install-plugins" target="_blank">Visual Composer</a></strong> plugin to be installed and activated on your site.’, $theme_data->get(‘Name’)).'</p>
</div>’;
}
}

//finally initialize code

new seoVCExtendAddonClass();

&nbsp;

?>

[/php]

Class 9

I’ve Registered a Post type for “Testimonial’ then made a shortcode where user can query a post by ‘Post type’,  ‘Item’, for post limit ‘Order’, for Ascending or Descending and so all. Finally I made a Visual Composer addon where user can handle all those features dynamically.

[php]

<?php
//registering post type
function seo_testimonial_custompost(){
register_post_type(‘testimonial’, array(
‘labels’ => array(
‘name’ => ‘Testimonial’,
‘add_new’ => ‘Add new Testimonial’
),
‘public’ => true,
‘supports’ => array(‘title’, ‘thumbnail’)
));
}
add_action(‘init’, ‘seo_testimonial_custompost’);

//shortcode
function seo_testimonial_shortcode($atts, $content = null){
extract(shortcode_atts(
array(
‘type’ => ‘post’,
‘item’ => 5,
‘order’ => ‘ASC’,
‘color’ => ‘color’,
‘icon’ => ‘icon’
), $atts
));

$q = new WP_Query(array(
‘post_type’ => $type,
‘posts_per_page’ => $item,
‘order’ => $order
));

$list = ‘<ul>’;
while($q->have_posts()) : $q->the_post();
$list .= ‘<li>’;
if(!empty($icon)){
$list .= ‘<i class="’.$icon.’"></i> ‘;
}
$list .= ‘<a href="’.get_permalink().’" style="color:’.$color.’">’.get_the_title().'</a></li>’;
endwhile;
$list .= ‘</ul>’;

return $list;
}
add_shortcode(‘post_list’, ‘seo_testimonial_shortcode’);

function seo_post_item_show(){
vc_map(array(
‘name’ => ‘Post Title’,
‘base’ => ‘post_list’,
‘category’ => ‘SEO’,
‘params’ => array(
array(
‘type’ => ‘textfield’,
‘heading’ => ‘Post Type’,
‘description’ => ‘Put post type here’,
‘value’ => ‘post’,
‘param_name’ => ‘type’
),
array(
‘type’ => ‘textfield’,
‘heading’ => ‘Post Item’,
‘description’ => ‘Put your item number’,
‘value’ => 1,
‘param_name’ => ‘item’
),
array(
‘type’ => ‘textfield’,
‘heading’ => ‘Post Order’,
‘description’ => ‘Put Post order’,
‘value’ => ‘ASC’,
‘param_name’ => ‘order’
),
array(
‘type’ => ‘colorpicker’,
‘heading’ => ‘Post Color’,
‘description’ => ‘Select post color’,
‘value’ => ‘#333333’,
‘param_name’ => ‘color’
),
array(
‘type’ => ‘iconpicker’,
‘heading’ => ‘Post Icon’,
‘description’ => ‘Select post Icon’,
‘value’ => ‘fa fa-leaf’,
‘param_name’ => ‘icon’
)
)
));
}
add_action(‘vc_before_init’, ‘seo_post_item_show’);
?>

[/php]

Class 8

[php]

<?php

//registering post type
function seo_testimonial_custompost(){
register_post_type(‘testimonial’, array(
‘labels’ => array(
‘name’ => ‘Testimonial’,
‘add_new’ => ‘Add new Testimonial’
),
‘public’ => true,
‘supports’ => array(‘title’, ‘thumbnail’)
));
}
add_action(‘init’, ‘seo_testimonial_custompost’);

//shortcode
function seo_testimonial_shortcode($atts, $content = null){
extract(shortcode_atts(
array(
‘type’ => ‘post’,
‘item’ => 5,
‘order’ => ‘ASC’
), $atts
));

$q = new WP_Query(array(
‘post_type’ => $type,
‘posts_per_page’ => $item,
‘order’ => $order
));

$list = ‘<ul>’;
while($q->have_posts()) : $q->the_post();
$list .= ‘<li><a href="’.get_permalink().’">’.get_the_title().'</a></li>’;
endwhile;
$list .= ‘</ul>’;

return $list;
}
add_shortcode(‘post_list’, ‘seo_testimonial_shortcode’);

?>

[/php]