| 1 |
<?php |
| 2 |
/** |
| 3 |
* Page Generator WordPress Plugin. |
| 4 |
* |
| 5 |
* @package Page_Generator_Pro |
| 6 |
* @author WP Zinc |
| 7 |
* |
| 8 |
* Plugin Name: Page Generator |
| 9 |
* Plugin URI: http://www.wpzinc.com/plugins/page-generator-pro |
| 10 |
* Version: 1.8.4 |
| 11 |
* Author: WP Zinc |
| 12 |
* Author URI: http://www.wpzinc.com |
| 13 |
* Description: Generate multiple Pages using dynamic content. |
| 14 |
*/ |
| 15 |
|
| 16 |
// Bail if Plugin is alread loaded. |
| 17 |
if ( class_exists( 'Page_Generator' ) ) { |
| 18 |
return; |
| 19 |
} |
| 20 |
|
| 21 |
// Bail if the Pro version of the Plugin is active. |
| 22 |
if ( class_exists( 'Page_Generator_Pro' ) ) { |
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 26 |
// Define Plugin version and build date. |
| 27 |
define( 'PAGE_GENERATOR_PLUGIN_VERSION', '1.8.4' ); |
| 28 |
define( 'PAGE_GENERATOR_PLUGIN_BUILD_DATE', '2026-04-02 12:00:00' ); |
| 29 |
|
| 30 |
// Define Plugin paths. |
| 31 |
define( 'PAGE_GENERATOR_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 32 |
define( 'PAGE_GENERATOR_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); |
| 33 |
|
| 34 |
/** |
| 35 |
* Define the autoloader for this Plugin |
| 36 |
* |
| 37 |
* @since 1.6.5 |
| 38 |
* |
| 39 |
* @param string $class_name The class to load. |
| 40 |
*/ |
| 41 |
function page_generator_autoloader( $class_name ) { |
| 42 |
|
| 43 |
/** |
| 44 |
* Load Plugin Class |
| 45 |
*/ |
| 46 |
$class_start_name = array( |
| 47 |
'Page_Generator_Pro', |
| 48 |
); |
| 49 |
|
| 50 |
// Get the number of parts the class start name has. |
| 51 |
$class_parts_count = count( explode( '_', $class_start_name[0] ) ); |
| 52 |
|
| 53 |
// Break the class name into an array. |
| 54 |
$class_path = explode( '_', $class_name ); |
| 55 |
|
| 56 |
// Bail if it's not a minimum length. |
| 57 |
if ( count( $class_path ) < $class_parts_count ) { |
| 58 |
return; |
| 59 |
} |
| 60 |
|
| 61 |
// Build the base class path for this class. |
| 62 |
$base_class_path = ''; |
| 63 |
for ( $i = 0; $i < $class_parts_count; $i++ ) { |
| 64 |
$base_class_path .= $class_path[ $i ] . '_'; |
| 65 |
} |
| 66 |
$base_class_path = trim( $base_class_path, '_' ); |
| 67 |
|
| 68 |
// Bail if the first parts don't match what we expect. |
| 69 |
if ( ! in_array( $base_class_path, $class_start_name, true ) ) { |
| 70 |
return; |
| 71 |
} |
| 72 |
|
| 73 |
// Define the file name we need to include. |
| 74 |
$file_name = strtolower( implode( '-', array_slice( $class_path, $class_parts_count ) ) ) . '.php'; |
| 75 |
|
| 76 |
// Define the paths with file name we need to include. |
| 77 |
$include_paths = array( |
| 78 |
__DIR__ . '/includes/admin/' . $file_name, |
| 79 |
__DIR__ . '/includes/admin/keyword-sources/' . $file_name, |
| 80 |
__DIR__ . '/includes/global/' . $file_name, |
| 81 |
); |
| 82 |
|
| 83 |
// Iterate through the include paths to find the file. |
| 84 |
foreach ( $include_paths as $path_file ) { |
| 85 |
if ( file_exists( $path_file ) ) { |
| 86 |
require_once $path_file; |
| 87 |
return; |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
} |
| 92 |
spl_autoload_register( 'page_generator_autoloader' ); |
| 93 |
|
| 94 |
// Load Activation and Deactivation functions. |
| 95 |
require_once PAGE_GENERATOR_PLUGIN_PATH . 'includes/activation.php'; |
| 96 |
require_once PAGE_GENERATOR_PLUGIN_PATH . 'includes/deactivation.php'; |
| 97 |
register_activation_hook( __FILE__, 'page_generator_activate' ); |
| 98 |
if ( version_compare( get_bloginfo( 'version' ), '5.1', '>=' ) ) { |
| 99 |
add_action( 'wp_insert_site', 'page_generator_activate_new_site' ); |
| 100 |
} else { |
| 101 |
add_action( 'wpmu_new_blog', 'page_generator_activate_new_site' ); |
| 102 |
} |
| 103 |
add_action( 'activate_blog', 'page_generator_activate_new_site' ); |
| 104 |
register_deactivation_hook( __FILE__, 'page_generator_deactivate' ); |
| 105 |
|
| 106 |
/** |
| 107 |
* Main function to return Plugin instance. |
| 108 |
* |
| 109 |
* @since 1.6.5 |
| 110 |
*/ |
| 111 |
function Page_Generator() { /* phpcs:ignore */ |
| 112 |
|
| 113 |
return Page_Generator::get_instance(); |
| 114 |
|
| 115 |
} |
| 116 |
|
| 117 |
// Finally, initialize the Plugin. |
| 118 |
require_once PAGE_GENERATOR_PLUGIN_PATH . 'includes/class-page-generator.php'; |
| 119 |
$page_generator = Page_Generator(); |
| 120 |
|