Plugin Directory

Changeset 2075179


Ignore:
Timestamp:
04/26/2019 07:06:16 AM (7 years ago)
Author:
ajency
Message:

added custom template support

Location:
event-codes
Files:
22 edited
1 copied

Legend:

Unmodified
Added
Removed
  • event-codes/tags/1.0.4/events/class-event-codes-shortcode-helper.php

    r1688336 r2075179  
    5555
    5656    function _return_no_events_markup() {
     57        $template_name = 'not-available.php';
     58        $template_path = 'event-codes/events/views/';
     59        $default_path = plugin_dir_path(dirname(__FILE__)).'events/views/';
     60       
    5761        ob_start();
    58         include plugin_dir_path(dirname(__FILE__)) . '/events/views/not-available.php';
     62        include $this->ec_locate_template($template_name, $template_path, $default_path);
    5963        return ob_get_clean();
    6064    }
     
    6266    function _return_events_markup_and_data($event_data,$atts) {
    6367        $shortcode_id = uniqid();
    64         ob_start();
    65         include plugin_dir_path(dirname(__FILE__)) . '/events/views/' . $atts['template'] . '/' . $atts['view'] . '-view.php';
     68        $template_name = $atts['view'] . '-view.php';
     69        $template_path = 'event-codes/events/views/' . $atts['template'] . '/';
     70        $default_path = plugin_dir_path(dirname(__FILE__)).'events/views/' . $atts['template'] . '/';
     71       
     72        ob_start();       
     73        include $this->ec_locate_template($template_name, $template_path, $default_path);
    6674        return ob_get_clean();
    6775    }
    6876
    6977    function _return_load_more_events_markup_and_data($event_data,$atts) {
    70         ob_start();
     78        $template_name = $atts['view'] . '-view-item.php';
     79        $template_path = 'event-codes/events/views/' . $atts['template'] . '/';
     80        $default_path = plugin_dir_path(dirname(__FILE__)).'events/views/' . $atts['template'] . '/';
     81     
     82        ob_start();       
    7183        foreach ($event_data->events as $event) {
    72             include plugin_dir_path(dirname(__FILE__)) . '/events/views/' . $atts['template'] . '/' . $atts['view'] . '-view-item.php';
     84            include $this->ec_locate_template($template_name, $template_path, $default_path);
    7385        }
    7486        return ob_get_clean();
     
    8496        return 'Event_Codes_Datasource_'.ucfirst($code_name);
    8597    }
     98   
     99   
     100    function ec_locate_template( $template_name, $template_path = '', $default_path = '' ) {
    86101
     102      // Set variable to search in the templates folder of theme.
     103      if ( ! $template_path ) :
     104        $template_path = 'event-codes/';
     105      endif;
     106
     107      // Set default plugin templates path.
     108      if ( ! $default_path ) :
     109        $default_path = plugin_dir_path( __FILE__ ); // Path to the template folder
     110      endif;
     111
     112      // Search template file in theme folder.
     113      $template = locate_template( array(
     114        $template_path . $template_name,
     115        $template_name
     116      ));         
     117
     118      // Get plugins template file.
     119      if ( ! $template ) :
     120        $template = $default_path . $template_name;
     121      endif;
     122
     123      return apply_filters( 'ec_locate_template', $template, $template_name, $template_path, $default_path );
     124    }
     125   
    87126}
  • event-codes/tags/1.0.4/events/views/bootstrap/list-view-item.php

    r1688336 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/bootstrap/list-view-item.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/tags/1.0.4/events/views/bootstrap/list-view.php

    r1747763 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/bootstrap/list-view.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/tags/1.0.4/events/views/bootstrap/tabular-view-item.php

    r1688336 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/bootstrap/tabular-view-item.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/tags/1.0.4/events/views/bootstrap/tabular-view.php

    r1747763 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/bootstrap/tabular-view.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/tags/1.0.4/events/views/normal/list-view-item.php

    r1688336 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/normal/list-view-item.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/tags/1.0.4/events/views/normal/list-view.php

    r1747763 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/normal/list-view.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/tags/1.0.4/events/views/normal/tabular-view-item.php

    r1688336 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/normal/tabular-view-item.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/tags/1.0.4/events/views/normal/tabular-view.php

    r1747763 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/normal/tabular-view.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/tags/1.0.4/events/views/not-available.php

    r1688336 r2075179  
    11<?php
    2 // If this file is called directly, abort.
     2 /*
     3  * This template can be overridden by copying it to yourtheme/event-codes/events/views/not-available.php
     4  *
     5  * If this file is called directly, abort.
     6  */
     7
    38if ( ! defined( 'WPINC' ) ) {
    49    die;
     
    712<div class="aj__no-events">
    813    No events available :(
    9 </div>'
     14</div>
  • event-codes/tags/1.0.4/readme.txt

    r2022783 r2075179  
    33Tags: event shortcode, event calendar shortcode, shortcodes, event, events, calendar, modern tribe
    44Requires at least: 4.1
    5 Tested up to: 4.9
    6 Stable tag: 1.0.3
     5Tested up to: 5.1
     6Stable tag: 1.0.4
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    188188== Changelog ==
    189189
     190= 1.0.4 =
     191* Feature - added custom template support
     192
    190193= 1.0.3 =
    191194* Feature - New shortcode option "skip-cat" added
  • event-codes/trunk/events/class-event-codes-shortcode-helper.php

    r1688336 r2075179  
    5555
    5656    function _return_no_events_markup() {
     57        $template_name = 'not-available.php';
     58        $template_path = 'event-codes/events/views/';
     59        $default_path = plugin_dir_path(dirname(__FILE__)).'events/views/';
     60       
    5761        ob_start();
    58         include plugin_dir_path(dirname(__FILE__)) . '/events/views/not-available.php';
     62        include $this->ec_locate_template($template_name, $template_path, $default_path);
    5963        return ob_get_clean();
    6064    }
     
    6266    function _return_events_markup_and_data($event_data,$atts) {
    6367        $shortcode_id = uniqid();
    64         ob_start();
    65         include plugin_dir_path(dirname(__FILE__)) . '/events/views/' . $atts['template'] . '/' . $atts['view'] . '-view.php';
     68        $template_name = $atts['view'] . '-view.php';
     69        $template_path = 'event-codes/events/views/' . $atts['template'] . '/';
     70        $default_path = plugin_dir_path(dirname(__FILE__)).'events/views/' . $atts['template'] . '/';
     71       
     72        ob_start();       
     73        include $this->ec_locate_template($template_name, $template_path, $default_path);
    6674        return ob_get_clean();
    6775    }
    6876
    6977    function _return_load_more_events_markup_and_data($event_data,$atts) {
    70         ob_start();
     78        $template_name = $atts['view'] . '-view-item.php';
     79        $template_path = 'event-codes/events/views/' . $atts['template'] . '/';
     80        $default_path = plugin_dir_path(dirname(__FILE__)).'events/views/' . $atts['template'] . '/';
     81     
     82        ob_start();       
    7183        foreach ($event_data->events as $event) {
    72             include plugin_dir_path(dirname(__FILE__)) . '/events/views/' . $atts['template'] . '/' . $atts['view'] . '-view-item.php';
     84            include $this->ec_locate_template($template_name, $template_path, $default_path);
    7385        }
    7486        return ob_get_clean();
     
    8496        return 'Event_Codes_Datasource_'.ucfirst($code_name);
    8597    }
     98   
     99   
     100    function ec_locate_template( $template_name, $template_path = '', $default_path = '' ) {
    86101
     102      // Set variable to search in the templates folder of theme.
     103      if ( ! $template_path ) :
     104        $template_path = 'event-codes/';
     105      endif;
     106
     107      // Set default plugin templates path.
     108      if ( ! $default_path ) :
     109        $default_path = plugin_dir_path( __FILE__ ); // Path to the template folder
     110      endif;
     111
     112      // Search template file in theme folder.
     113      $template = locate_template( array(
     114        $template_path . $template_name,
     115        $template_name
     116      ));         
     117
     118      // Get plugins template file.
     119      if ( ! $template ) :
     120        $template = $default_path . $template_name;
     121      endif;
     122
     123      return apply_filters( 'ec_locate_template', $template, $template_name, $template_path, $default_path );
     124    }
     125   
    87126}
  • event-codes/trunk/events/views/bootstrap/list-view-item.php

    r1688336 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/bootstrap/list-view-item.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/trunk/events/views/bootstrap/list-view.php

    r1747763 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/bootstrap/list-view.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/trunk/events/views/bootstrap/tabular-view-item.php

    r1688336 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/bootstrap/tabular-view-item.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/trunk/events/views/bootstrap/tabular-view.php

    r1747763 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/bootstrap/tabular-view.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/trunk/events/views/normal/list-view-item.php

    r1688336 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/normal/list-view-item.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/trunk/events/views/normal/list-view.php

    r1747763 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/normal/list-view.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/trunk/events/views/normal/tabular-view-item.php

    r1688336 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/normal/tabular-view-item.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/trunk/events/views/normal/tabular-view.php

    r1747763 r2075179  
    11<?php
     2/*
     3* This template can be overridden by copying it to yourtheme/event-codes/events/views/normal/tabular-view.php
     4*/
    25// If this file is called directly, abort.
    36if ( ! defined( 'WPINC' ) ) {
  • event-codes/trunk/events/views/not-available.php

    r1688336 r2075179  
    11<?php
    2 // If this file is called directly, abort.
     2 /*
     3  * This template can be overridden by copying it to yourtheme/event-codes/events/views/not-available.php
     4  *
     5  * If this file is called directly, abort.
     6  */
     7
    38if ( ! defined( 'WPINC' ) ) {
    49    die;
     
    712<div class="aj__no-events">
    813    No events available :(
    9 </div>'
     14</div>
  • event-codes/trunk/readme.txt

    r2022783 r2075179  
    33Tags: event shortcode, event calendar shortcode, shortcodes, event, events, calendar, modern tribe
    44Requires at least: 4.1
    5 Tested up to: 4.9
    6 Stable tag: 1.0.3
     5Tested up to: 5.1
     6Stable tag: 1.0.4
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    188188== Changelog ==
    189189
     190= 1.0.4 =
     191* Feature - added custom template support
     192
    190193= 1.0.3 =
    191194* Feature - New shortcode option "skip-cat" added
Note: See TracChangeset for help on using the changeset viewer.