| 1 |
<?php |
| 2 |
/** |
| 3 |
* The plugin bootstrap file |
| 4 |
* |
| 5 |
* This file is read by WordPress to generate the plugin information in the plugin |
| 6 |
* admin area. This file also includes all of the dependencies used by the plugin, |
| 7 |
* registers the activation and deactivation functions, and defines a function |
| 8 |
* that starts the plugin. |
| 9 |
* |
| 10 |
* @link https://easyprolabs.com |
| 11 |
* @since 1.0.0 |
| 12 |
* @package Display_Post_Types |
| 13 |
* |
| 14 |
* @wordpress-plugin |
| 15 |
* Plugin Name: Display Post Types |
| 16 |
* Description: Filter, sort and display post, page or any post type. |
| 17 |
* Version: 3.2.8 |
| 18 |
* Author: easyprolabs |
| 19 |
* Author URI: https://easyprolabs.com/display-post-types/ |
| 20 |
* License: GPL-3.0+ |
| 21 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt |
| 22 |
* Text Domain: display-post-types |
| 23 |
* Domain Path: /lang |
| 24 |
*/ |
| 25 |
|
| 26 |
// If this file is called directly, abort. |
| 27 |
if ( ! defined( 'WPINC' ) ) { |
| 28 |
die; |
| 29 |
} |
| 30 |
|
| 31 |
// Currently plugin version. |
| 32 |
if ( ! defined( 'DISPLAY_POST_TYPES_VERSION' ) ) { |
| 33 |
define( 'DISPLAY_POST_TYPES_VERSION', '3.2.8' ); |
| 34 |
} |
| 35 |
|
| 36 |
// Define plugin constants. |
| 37 |
if ( ! defined( 'DISPLAY_POST_TYPES_DIR' ) ) { |
| 38 |
define( 'DISPLAY_POST_TYPES_DIR', plugin_dir_path( __FILE__ ) ); |
| 39 |
} |
| 40 |
|
| 41 |
// Define plugin constants. |
| 42 |
if ( ! defined( 'DISPLAY_POST_TYPES_URL' ) ) { |
| 43 |
define( 'DISPLAY_POST_TYPES_URL', plugin_dir_url( __FILE__ ) ); |
| 44 |
} |
| 45 |
|
| 46 |
// Define plugin constants. |
| 47 |
if ( ! defined( 'DISPLAY_POST_TYPES_BASENAME' ) ) { |
| 48 |
define( 'DISPLAY_POST_TYPES_BASENAME', plugin_basename( __FILE__ ) ); |
| 49 |
} |
| 50 |
|
| 51 |
// Register PHP autoloader. |
| 52 |
spl_autoload_register( |
| 53 |
function( $class ) { |
| 54 |
$namespace = 'Display_Post_Types\\'; |
| 55 |
|
| 56 |
// Bail if the class is not in our namespace. |
| 57 |
if ( 0 !== strpos( $class, $namespace ) ) { |
| 58 |
return; |
| 59 |
} |
| 60 |
|
| 61 |
// Get classname without namespace. |
| 62 |
$carray = array_values( explode( '\\', $class ) ); |
| 63 |
$clast = count( $carray ) - 1; |
| 64 |
|
| 65 |
// Return if proper array is not available. (Just in case). |
| 66 |
if ( ! $clast ) { |
| 67 |
return; |
| 68 |
} |
| 69 |
|
| 70 |
// Prepend actual classname with 'class-' prefix. |
| 71 |
$carray[ $clast ] = 'class-' . $carray[ $clast ]; |
| 72 |
$class = implode( '\\', $carray ); |
| 73 |
|
| 74 |
// Generate file path from classname. |
| 75 |
$path = strtolower( |
| 76 |
str_replace( |
| 77 |
array( $namespace, '_' ), |
| 78 |
array( '', '-' ), |
| 79 |
$class |
| 80 |
) |
| 81 |
); |
| 82 |
|
| 83 |
// Build full filepath. |
| 84 |
$file = DISPLAY_POST_TYPES_DIR . DIRECTORY_SEPARATOR . str_replace( '\\', DIRECTORY_SEPARATOR, $path ) . '.php'; |
| 85 |
|
| 86 |
// If the file exists for the class name, load it. |
| 87 |
if ( file_exists( $file ) ) { |
| 88 |
include $file; |
| 89 |
} |
| 90 |
} |
| 91 |
); |
| 92 |
|
| 93 |
add_action( |
| 94 |
'plugins_loaded', |
| 95 |
function() { |
| 96 |
// Register Display Post Types front-end hooks. |
| 97 |
Display_Post_Types\Frontend\Register::init(); |
| 98 |
|
| 99 |
// Register Display Post Types back-end hooks. |
| 100 |
Display_Post_Types\Backend\Register::init(); |
| 101 |
}, |
| 102 |
8 |
| 103 |
); |
| 104 |
|
| 105 |
// Load premium features (if exist). |
| 106 |
if ( file_exists( DISPLAY_POST_TYPES_DIR . '/dpt-pro/dpt-pro.php' ) ) { |
| 107 |
require_once DISPLAY_POST_TYPES_DIR . '/dpt-pro/dpt-pro.php'; |
| 108 |
} |
| 109 |
|