pods
Last commit date
classes
2 years ago
components
2 years ago
deprecated
2 years ago
includes
2 years ago
sql
2 years ago
src
2 years ago
ui
2 years ago
vendor
2 years ago
changelog.txt
2 years ago
init.php
2 years ago
license.txt
10 years ago
readme.txt
2 years ago
init.php
179 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Pods - Custom Content Types and Fields |
| 4 | * |
| 5 | * @package Pods |
| 6 | * @author Pods Framework Team |
| 7 | * @copyright 2024 Pods Foundation, Inc |
| 8 | * @license GPL v2 or later |
| 9 | * |
| 10 | * Plugin Name: Pods - Custom Content Types and Fields |
| 11 | * Plugin URI: https://pods.io/ |
| 12 | * Description: Pods is a framework for creating, managing, and deploying customized content types and fields |
| 13 | * Version: 3.2.2 |
| 14 | * Author: Pods Framework Team |
| 15 | * Author URI: https://pods.io/about/ |
| 16 | * Text Domain: pods |
| 17 | * License: GPL v2 or later |
| 18 | * License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 19 | * Requires at least: 6.0 |
| 20 | * Requires PHP: 7.2 |
| 21 | * GitHub Plugin URI: https://github.com/pods-framework/pods |
| 22 | * Primary Branch: main |
| 23 | */ |
| 24 | |
| 25 | /* |
| 26 | * This program is free software: you can redistribute it and/or modify |
| 27 | * it under the terms of the GNU General Public License as published by |
| 28 | * the Free Software Foundation, either version 2 of the License, or |
| 29 | * any later version. |
| 30 | * |
| 31 | * This program is distributed in the hope that it will be useful, |
| 32 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 33 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 34 | * GNU General Public License for more details. |
| 35 | * |
| 36 | * You should have received a copy of the GNU General Public License |
| 37 | * along with this program. If not, see https://www.gnu.org/licenses/gpl-2.0.html. |
| 38 | */ |
| 39 | |
| 40 | if ( defined( 'PODS_VERSION' ) || defined( 'PODS_DIR' ) ) { |
| 41 | // Prevent conflicts with Pods 1.x and Pods UI plugins. |
| 42 | add_action( 'init', 'pods_deactivate_pods_duplicate' ); |
| 43 | add_action( 'init', 'pods_deactivate_pods_ui' ); |
| 44 | } else { |
| 45 | // Current version. |
| 46 | define( 'PODS_VERSION', '3.2.2' ); |
| 47 | |
| 48 | // Current database version, this is the last version the database changed. |
| 49 | define( 'PODS_DB_VERSION', '2.3.5' ); |
| 50 | |
| 51 | /** |
| 52 | * We aim to keep this as recent as possible to avoid ongoing React/Gutenberg compatibility problems. |
| 53 | * |
| 54 | * This should always be -2 versions behind the latest WP release. Example: 5.5 if 5.7 is current. |
| 55 | * |
| 56 | * To be updated each Major x.x Pods release. |
| 57 | */ |
| 58 | if ( ! defined( 'PODS_WP_VERSION_MINIMUM' ) ) { |
| 59 | define( 'PODS_WP_VERSION_MINIMUM', '6.0' ); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * This should match minimum WP requirements or usage of 90%+. |
| 64 | * |
| 65 | * Found at: https://wordpress.org/about/stats/ |
| 66 | * |
| 67 | * Next planned minimum PHP version: 7.2 (to match WooCommerce and others pushing WP forward). |
| 68 | */ |
| 69 | if ( ! defined( 'PODS_PHP_VERSION_MINIMUM' ) ) { |
| 70 | define( 'PODS_PHP_VERSION_MINIMUM', '7.2' ); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * This should match minimum WP requirements or usage of 90%+. |
| 75 | * |
| 76 | * Found at: https://wordpress.org/about/stats/ |
| 77 | */ |
| 78 | if ( ! defined( 'PODS_MYSQL_VERSION_MINIMUM' ) ) { |
| 79 | define( 'PODS_MYSQL_VERSION_MINIMUM', '5.5' ); |
| 80 | } |
| 81 | |
| 82 | define( 'PODS_FILE', __FILE__ ); |
| 83 | define( 'PODS_SLUG', plugin_basename( __FILE__ ) ); |
| 84 | define( 'PODS_URL', plugin_dir_url( __FILE__ ) ); |
| 85 | define( 'PODS_DIR', plugin_dir_path( __FILE__ ) ); |
| 86 | |
| 87 | // Prevent conflicts with old Pods UI plugin |
| 88 | if ( function_exists( 'pods_ui_manage' ) ) { |
| 89 | add_action( 'init', 'pods_deactivate_pods_ui' ); |
| 90 | } else { |
| 91 | // If there was an install/update failure and the sub directories do not exist. Bail to avoid fatal errors. |
| 92 | if ( |
| 93 | ! file_exists( PODS_DIR . 'classes/PodsInit.php' ) |
| 94 | || ! file_exists( PODS_DIR . 'vendor/vendor-prefixed/autoload.php' ) |
| 95 | ) { |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | global $pods, $pods_init, $pods_form; |
| 100 | |
| 101 | // Init custom autoloader. |
| 102 | require_once PODS_DIR . 'classes/PodsInit.php'; |
| 103 | |
| 104 | spl_autoload_register( array( 'PodsInit', 'autoload_class' ) ); |
| 105 | |
| 106 | require_once PODS_DIR . 'vendor/vendor-prefixed/autoload.php'; |
| 107 | |
| 108 | // Include global functions. |
| 109 | require_once PODS_DIR . 'includes/access.php'; |
| 110 | require_once PODS_DIR . 'includes/classes.php'; |
| 111 | require_once PODS_DIR . 'includes/data.php'; |
| 112 | require_once PODS_DIR . 'includes/forms.php'; |
| 113 | require_once PODS_DIR . 'includes/general.php'; |
| 114 | |
| 115 | // Maybe include media functions. |
| 116 | if ( ! defined( 'PODS_MEDIA' ) || PODS_MEDIA ) { |
| 117 | require_once PODS_DIR . 'includes/media.php'; |
| 118 | } |
| 119 | |
| 120 | // Maybe run full init. |
| 121 | if ( ! defined( 'SHORTINIT' ) || ! SHORTINIT ) { |
| 122 | // Maybe include deprecated classes / functions. |
| 123 | if ( pods_allow_deprecated() ) { |
| 124 | require_once PODS_DIR . 'deprecated/deprecated.php'; |
| 125 | } |
| 126 | |
| 127 | // Check if minimum required versions are met. |
| 128 | if ( false !== pods_compatibility_check() ) { |
| 129 | $pods_form = pods_form(); |
| 130 | |
| 131 | // If not on network admin, run full init. |
| 132 | if ( ! is_network_admin() ) { |
| 133 | $pods_init = pods_init(); |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Deactivate this version of Pods if Pods is already included. |
| 142 | * |
| 143 | * @since 2.8.0 |
| 144 | */ |
| 145 | function pods_deactivate_pods_duplicate() { |
| 146 | if ( defined( 'PODS_VERSION' ) && defined( 'PODS_DIR' ) && file_exists( untrailingslashit( PODS_DIR ) . '/init.php' ) ) { |
| 147 | if ( ! function_exists( 'deactivate_plugins' ) ) { |
| 148 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 149 | } |
| 150 | |
| 151 | deactivate_plugins( realpath( untrailingslashit( PODS_DIR ) . '/init.php' ) ); |
| 152 | |
| 153 | if ( ! headers_sent() && ( ! function_exists( 'pods_ui_manage' ) && ! file_exists( WP_CONTENT_DIR . 'plugins/pods-ui/pods-ui.php' ) ) ) { |
| 154 | wp_redirect( $_SERVER['REQUEST_URI'] ); |
| 155 | die(); |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Deactivate Pods UI plugin if already included. |
| 162 | * |
| 163 | * @since 2.0.0 |
| 164 | */ |
| 165 | function pods_deactivate_pods_ui() { |
| 166 | if ( function_exists( 'pods_ui_manage' ) && file_exists( WP_CONTENT_DIR . 'plugins/pods-ui/pods-ui.php' ) ) { |
| 167 | if ( ! function_exists( 'deactivate_plugins' ) ) { |
| 168 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 169 | } |
| 170 | |
| 171 | deactivate_plugins( realpath( WP_CONTENT_DIR . 'plugins/pods-ui/pods-ui.php' ) ); |
| 172 | |
| 173 | if ( ! headers_sent() ) { |
| 174 | wp_redirect( $_SERVER['REQUEST_URI'] ); |
| 175 | die(); |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 |