Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Factorian Toolkit
- Plugin URI: http://salmancreation.com
- Author: Salman Ahmed
- Version: 1.0
- Description: Factorian WordPress Theme Plugin Toolkit . All Shortcodes & VC-Addons . Please Active This . Thank you
- */
- // don't load directly
- if ( ! defined( 'ABSPATH' ) ) {
- exit;
- }
- // Define
- define('Factorian_ACC_URL', WP_PUGIN_URL .'/'. plugin_basename( dirname(__FILE__) ) . '/' );
- define('Factorian_ACC_PATH', plugin_dir_path( __FILE__ ));
- // Shortcode widget support
- add_filter('widget_text','do_shortcode');
- require_once(Factorian_ACC_PATH . 'vc-addons/vc-blocks-load.php' );
- require_once(Factorian_ACC_PATH . 'theme-shortcodes/slides-shortcode.php' );
- function factorian_toolkit_file(){
- wp_enqueue_style( 'owl-carousel', PLUGINS_URL('assets/css/owl.carousel.css', __FILE__));
- wp_enqueue_style( 'owl-transition', PLUGINS_URL('assets/css/owl.transitions.css', __FILE__));
- wp_enqueue_script( 'owl-carousel-js', PLUGINS_URL('assets/js/owl.carousel.min.js', __FILE__), array('jquery'), '1.3', true );
- }
- add_action('wp_enqueue_scripts','factorian_toolkit_file');
- // Progressbar shortcode
- function factorian_progressbar_shortcode($atts){
- extract( shortcode_atts( array(
- 'count' => '50',
- 'animate' => 'yes',
- 'color' => '#c22',
- ), $atts) );
- if($animate =='yes'){
- $progressbar='<div class="progress">
- <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="'.$count.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$count.'%;background-color:'.$color.';"> '.$count.'%
- </div>
- </div>';
- }
- elseif($animate =='no'){
- $progressbar='<div class="progress">
- <div class="progress-bar progress-bar-striped" role="progressbar" aria-valuenow="'.$count.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$count.'%;background-color:'.$color.';"> '.$count.'%
- </div>
- </div>';
- }
- return $progressbar;
- }
- add_shortcode('factorian_progressbar', 'factorian_progressbar_shortcode');
- // tooltip shortcode
- function factorian_tooltip_shortcode($atts){
- extract( shortcode_atts( array(
- 'placement' => 'left',
- 'text' => ''
- ), $atts) );
- return '<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="'.$placement.'" title="Tooltip on '.$placement.'">'.$text.'</button>';
- }
- add_shortcode('factorian_tooltip', 'factorian_tooltip_shortcode');
- function factorian_post_list_shortcode($atts){
- extract( shortcode_atts( array(
- 'count' => -1,
- ), $atts) );
- $q = new WP_Query(
- array(
- 'posts_per_page' => $count,
- 'post_type' => 'factorian-slider',
- 'orderby' => 'menu_order',
- 'order' => 'ASC'
- )
- );
- $list = '<div class="custom_post_list">';
- while($q->have_posts()) : $q->the_post();
- $idd = get_the_ID();
- $custom_field = get_post_meta($idd, 'custom_field', true);
- $post_content = get_the_content();
- $list .= '
- <div style="background-image:url('.get_the_post_thumbnail_url($idd, 'large' ).')" class="single_post_item">
- <h2>' .do_shortcode( get_the_title() ). '</h2>
- '.wpautop( $post_content ).'
- <p>'.$custom_field.'</p>
- </div>
- ';
- endwhile;
- $list.= '</div>';
- wp_reset_query();
- return $list;
- }
- add_shortcode('factorian_post_list', 'factorian_post_list_shortcode');
- /* Factorian Theme VC Addons*/
- function factorian_vc_addons(){
- vc_map( array(
- "name" => __( "Slider Post List", "factorian-sctheme" ),
- "base" => "factorian_post_list",
- "icon" => "https://en.share-gate.com/app/archive/media/Sharegate/Images/2013/header_IMGSlider_616161.jpg",
- "category" => __( "Factorian", "factorian-sctheme"),
- 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
- 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
- "params" => array(
- array(
- "type" => "textfield",
- "heading" => __( "Post Count", "factorian-sctheme" ),
- "param_name" => "count",
- "value" => __( "2", "factorian-sctheme" ),
- "description" => __( "Type How many posts.", "factorian-sctheme" )
- )
- )
- ) );
- vc_map( array(
- "name" => __( "Progressbar", "factorian-sctheme" ),
- "base" => "factorian_progressbar",
- "icon" => "http://mobiuslearning.com/site/wp-content/uploads/2015/02/Icon-ProgressBar-300x169.png",
- "category" => __( "Factorian", "factorian-sctheme"),
- 'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
- 'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
- "params" => array(
- array(
- "type" => "textfield",
- "heading" => __( "Progressbar Value", "factorian-sctheme" ),
- "param_name" => "count",
- "value" => __( "50", "factorian-sctheme" ),
- "description" => __( "Type The Value.", "factorian-sctheme" )
- ),
- array(
- "type" => "colorpicker",
- "heading" => __( "Progressbar Color", "factorian-sctheme" ),
- "param_name" => "color",
- "value" => __( "#c33", "factorian-sctheme" ),
- "description" => __( "Select Your Color.", "factorian-sctheme" )
- ),
- array(
- "type" => "dropdown",
- "heading" => __( "Progressbar Animate", "factorian-sctheme" ),
- "param_name" => "animate",
- "value" => array(
- "Yes" => "yes",
- "NO" => "no"
- ),
- "description" => __( "Select Your Color.", "factorian-sctheme" )
- ),
- )
- ) );
- }
- add_action('vc_before_init','factorian_vc_addons');
- // Slider shortcode
- function factorian_slider_shortcode($atts){
- extract( shortcode_atts( array(
- 'count' => '',
- ), $atts) );
- $q = new WP_Query(
- array(
- 'posts_per_page' => $count,
- 'post_type' => 'factorian-slider'
- )
- );
- $factorian_slider ='<script>
- jQuery(document).ready(function($){
- $(".factorian_slider").owlCarousel({
- items: 1,
- loop: true,
- autoplay: false,
- nav: true,
- dots: true,
- navText: ["<i class=\'fa fa-agnle-left\'></i>","<i class=\'fa fa-agnle-right\'></i>"],
- });
- });
- </script> <div class="factorian_slider">';
- while($q->have_posts()) : $q->the_post();
- $idd = get_the_ID();
- $slide_meta = get_post_meta($idd, 'factorian_slider_options', true);
- $post_content = get_the_content();
- $factorian_slider .='
- <div style="background-image:url('.get_the_post_thumbnail_url($idd, 'large' ).')" class="single_slider">
- <div class="slider_tabel">
- <div class="slider_tabel_cell">
- <div class="container">
- <div class="row">
- <div class="col-md-6 col-md-offset-6">
- <h1>'.do_shortcode( get_the_title() ).'</h1>
- <h3>'.wpautop( $post_content ).'</h3>';
- if(!empty($slide_meta['buttons'])) {
- $factorian_slider.='<div class="slide_button">';
- foreach ($slide_meta['buttons'] as $button) {
- if ($button['button_link'] == 1) {
- $btn_link = get_page_link($button['button_link_to_wp_page']);
- } else{
- $btn_link = $button['button_link_to_external_page'];
- }
- $factorian_slider .='<a href="'.$btn_link.'" class="'.$button['button_type'].'_btn slide_btn_button"></a>';
- }
- $factorian_slider .='</div>';
- }
- $factorian_slider .='
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>';
- endwhile;
- $factorian_slider.= '</div>';
- wp_reset_query();
- return $factorian_slider;
- }
- add_shortcode('factorian_slider', 'factorian_slider_shortcode');
- // Register Slider Post Type
- function factorian_custom_post_resgister() {
- $labels = array(
- 'name' => _x( 'Factorian Slider', 'Post type general name', 'factorian-sctheme' ),
- 'singular_name' => _x( 'Factorian Slider', 'Post type singular name', 'factorian-sctheme' ),
- 'menu_name' => _x( 'Factorian Slider', 'Admin Menu text', 'factorian-sctheme' ),
- 'name_admin_bar' => _x( 'Slider', 'Add New on Toolbar', 'factorian-sctheme' ),
- 'add_new' => __( 'Add New Slider', 'factorian-sctheme' ),
- 'add_new_item' => __( 'Add New Slider', 'factorian-sctheme' ),
- 'new_item' => __( 'New Slider', 'factorian-sctheme' ),
- 'edit_item' => __( 'Edit Slider', 'factorian-sctheme' ),
- 'view_item' => __( 'View Slider', 'factorian-sctheme' ),
- 'all_items' => __( 'All Slider', 'factorian-sctheme' ),
- 'search_items' => __( 'Search Slider', 'factorian-sctheme' ),
- 'parent_item_colon' => __( 'Parent Slider:', 'factorian-sctheme' ),
- 'not_found' => __( 'No slider found.', 'factorian-sctheme' ),
- );
- $args = array(
- 'labels' => $labels,
- 'public' => flase,
- 'show_ui' => true,
- 'supports' => array( 'title', 'editor', 'thumbnail'),
- 'menu_icon' => 'dashicons-slides'
- );
- register_post_type( 'factorian-slider', $args );
- }
- add_action( 'init', 'factorian_custom_post_resgister' );
- wp_enqueue_style( 'factorian-shortcode', get_template_directory_uri() . '/assets/css/shortcode.css', array(), '1.0');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement