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');
- // file include
- require_once(Factorian_ACC_PATH . 'vc-addons/vc-blocks-load.php' );
- require_once(Factorian_ACC_PATH . 'theme-shortcodes/slides-shortcode.php' );
- require_once(Factorian_ACC_PATH . 'vc-addons/vc-slide.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 ='
- <ul 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 .= '
- <li class="single_post_item">
- <h2>' .do_shortcode( get_the_title() ). '</h2>
- '.wpautop( $post_content ).'
- <p>'.$custom_field.'</p>
- </li>
- ';
- endwhile;
- $list.= '</ul>';
- 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" => "http://simpleicon.com/wp-content/uploads/list.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" => __( "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"
- ),
- ),
- )
- ) );
- // slider vc addon
- }
- add_action('vc_before_init','factorian_vc_addons');
- function factorian_toolkit_get_post_as_list( ) {
- $args = wp_parse_args( array(
- 'post_type' => 'factorian-slider',
- 'numberposts' => -1,
- ) );
- $posts = get_posts($args);
- $post_options = array(esc_html__('-- Select Slide --', 'factorian-toolkit')=>'');
- if($posts) {
- foreach ($posts as $post) {
- $post_options[ $post->post_title ] = $post->ID;
- }
- }
- return $post_options;
- }
- // Slider shortcode
- function factorian_slider_shortcode($atts){
- extract( shortcode_atts( array(
- 'count' => 3,
- 'slide_id' => '',
- 'height' => '590',
- 'loop' => 'true',
- 'autoPlay' => 'true',
- 'autoPlayTimeOut' => 500,
- 'pagination' => '',
- 'navigation' => 'true',
- ), $atts) );
- if ($count == 1) {
- $q = new WP_Query(array('posts_per_page' => $count, 'post_type' => 'factorian-slider', 'p' => $slide_id ));
- } else {
- $q = new WP_Query(array('posts_per_page' => $count, 'post_type' => 'factorian-slider'));
- }
- if ($count == 1) {
- $factorian_slider ='';
- } else {
- $factorian_slider ='<script>
- jQuery(window).load(function(){
- jQuery(".factorian_slider").owlCarousel({
- items: 1,
- mouseDrag: false,
- slideSpeed : '.$autoPlayTimeOut.',
- autoPlay : '.$autoPlay.',
- loop:'.$loop.',
- pagination:'.$pagination.',
- navigation:'.$navigation.',
- navigationText: ["<i class=\'fa fa-angle-left\'></i>","<i class=\'fa fa-angle-right\'></i>"]
- });
- });
- </script>';
- }
- $factorian_slider .='
- <div id="slide" class="factorian_slider">';
- while($q->have_posts()) : $q->the_post();
- $idd = get_the_ID();
- if(get_post_meta($idd, 'factorian_slider_options', true)) {
- $slide_meta = get_post_meta($idd, 'factorian_slider_options', true);
- } else{
- $slide_meta = array();
- }
- if(array_key_exists('over_lay', $slide_meta)){
- $over_lay = $slide_meta['over_lay'];
- }else{
- $over_lay = true;
- }
- if(array_key_exists('over_lay_amout', $slide_meta)){
- $over_lay_amout = $slide_meta['over_lay_amout'];
- }else{
- $over_lay_amout = .5;
- }
- if(array_key_exists('overlay_color', $slide_meta)){
- $overlay_color = $slide_meta['overlay_color'];
- }else{
- $overlay_color = '#000';
- }
- $post_content = get_the_content();
- $factorian_slider .='
- <div style="background-image:url('.get_the_post_thumbnail_url($idd, 'large' ).'); height:'.$height.'px;" class="single_slider">';
- if ($over_lay == true) {
- $factorian_slider .='<div style="opacity:'.$over_lay_amout.';background-color:'.$overlay_color.'" class="slide_overlay"></div>';
- }
- $factorian_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">'.$button['button_text'].'</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', PLUGINS_URL('assets/css/shortcode.css', __FILE__));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement