Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( ! defined( 'ABSPATH' ) ) {
- exit; // Exit if accessed directly
- }
- //Performer Scroller
- add_shortcode( 'themeum_advertisement_shortcode', function($atts, $content = null){
- extract(shortcode_atts(array(
- 'title' => '',
- 'ads_type' => 'ads_cat',
- 'advertisement_cat' => 'themeumall',
- 'advertisement_post'=> ''
- 'class' => ''
- ), $atts));
- global $post;
- $args = '';
- if( $ads_type == "ads_cat" ){
- if( $advertisement_cat != 'themeumall' ){
- $args = array(
- 'post_type' => 'advertisement',
- 'tax_query' => array(
- array(
- 'taxonomy' => 'advertisement_cat',
- 'field' => 'slug',
- 'terms' => $advertisement_cat,
- ),
- ),
- 'posts_per_page' => 1,
- 'orderby' => 'rand',
- 'post_status' => 'publish',
- );
- }else{
- $args = array(
- 'post_type' => 'advertisement',
- 'posts_per_page' => 1,
- 'orderby' => 'rand',
- 'post_status' => 'publish',
- );
- }
- }else{
- $args = array(
- 'name' => $advertisement_post,
- 'post_type' => 'advertisement',
- 'post_status' => 'publish',
- 'posts_per_page' => 1
- );
- }
- $data = get_posts( $args );
- $output = '<div class="themeum-ads '.esc_attr( $class ).' ">';
- if($title) {
- $output .= '<h3 class="ads-style">' . esc_attr($title) . '</h3>';
- }
- foreach ( $data as $key=>$post ) {
- setup_postdata( $post );
- $link = get_post_meta( get_the_ID(), 'themeum_link', true);
- if( $link != '' ){ $output .= '<a href="'.esc_url($link).'">'; }
- $output .= get_the_post_thumbnail( $post->ID ,'full', array('class' => 'img-responsive') );
- if( $link != '' ){ $output .= '</a>'; }
- }
- wp_reset_postdata();
- $output .= '</div>';
- return $output;
- });
- //Visual Composer
- if (class_exists('WPBakeryVisualComposerAbstract')) {
- vc_map(array(
- "name" => __("Advertisement Shortcode", "themeum-advertiser"),
- "base" => "themeum_advertisement_shortcode",
- 'icon' => 'icon-wpb-advertisement',
- "class" => "",
- "description" => __("Themeum Advertisement","themeum-advertiser"),
- "category" => __("New Edge", "themeum-advertiser"),
- "params" => array(
- array(
- "type" => "textfield",
- "heading" => __("Title", "themeum-advertiser"),
- "param_name" => "title",
- "description" => __("Title of Advertisement", "themeum-advertiser"),
- "value" => "",
- "admin_label"=>true,
- ),
- // Dropdown
- array(
- "type" => "dropdown",
- "class" => "",
- "heading" => __("Ads Type","themeum-advertiser"),
- "param_name" => "ads_type",
- "value" => array(
- "Category" => "ads_cat",
- "Single Post" => "ads_single",
- ),
- ),
- array(
- "type" => "dropdown",
- "heading" => __("Select Advertisement Category:","themeum-advertiser"),
- "param_name" => "advertisement_cat",
- "value" => themeum_cat_list( 'advertisement_cat' ),
- "dependency" => Array("element" => "ads_type","value" => array("ads_cat")),
- ),
- array(
- "type" => "dropdown",
- "heading" => __("Select Advertisement Post:","themeum-advertiser"),
- "param_name" => "advertisement_post",
- "value" => themeum_all_post_list(),
- "dependency" => Array("element" => "ads_type","value" => array("ads_single")),
- ),
- array(
- "type" => "textfield",
- "heading" => esc_html__("Custom Class", 'newedge'),
- "param_name" => "class",
- "value" => "",
- )
- )
- ));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement