wp-parsidate.php
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Plugin Name: WP-Parsidate |
| 5 | * Version: 6.0 |
| 6 | * Plugin URI: https://wp-parsi.com/support/ |
| 7 | * Description: Persian package for WordPress, Adds full RTL and Shamsi (Jalali) support for: posts, comments, pages, archives, search, categories, permalinks and all admin sections and TinyMce editor, lists, quick editor. This package has Jalali archive widget. |
| 8 | * Author: WP-Parsi Team |
| 9 | * Author URI: https://wp-parsi.com/ |
| 10 | * Text Domain: wp-parsidate |
| 11 | * Domain Path: /languages |
| 12 | * Requires at least: 5.3 |
| 13 | * Requires PHP: 7.4 |
| 14 | * WC tested up to: 10.7.0 |
| 15 | * License: GPLv3 |
| 16 | * |
| 17 | * WP-Parsidate is free software: you can redistribute it and/or modify |
| 18 | * it under the terms of the GNU General Public License as published by |
| 19 | * the Free Software Foundation, either version 2 of the License, or |
| 20 | * any later version. |
| 21 | * |
| 22 | * WP-Parsidate is distributed in the hope that it will be useful, |
| 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 | * GNU General Public License for more details. |
| 26 | * |
| 27 | * You should have received a copy of the GNU General Public License |
| 28 | * along with WP-Parsidate. |
| 29 | * |
| 30 | * |
| 31 | * WordPress Parsi Package, Adds Persian language & Jalali date support to your blog |
| 32 | * |
| 33 | * Developers: |
| 34 | * Mobin Ghasempoor ( Developer & Founder ) |
| 35 | * Morteza Geransayeh ( Developer & Founder ) |
| 36 | * HamidReza Yazdani ( Developer ) |
| 37 | * Saeed Fard ( Analyst & Developer ) |
| 38 | * Parsa Kafi ( Developer ) |
| 39 | * |
| 40 | * @author Mobin Ghasempoor |
| 41 | * @author Morteza Geransayeh |
| 42 | * @link https://wp-parsi.com/ |
| 43 | * @version 5.1.6 |
| 44 | * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public License v3.0 |
| 45 | * @package WP-Parsidate |
| 46 | * @subpackage Core |
| 47 | */ |
| 48 | |
| 49 | namespace WPParsidate; |
| 50 | |
| 51 | defined( 'ABSPATH' ) || exit; |
| 52 | |
| 53 | use WPParsidate\Addons\Addons; |
| 54 | use WPParsidate\Admin\Admin; |
| 55 | use WPParsidate\App\App; |
| 56 | use WPParsidate\Core\Core; |
| 57 | use WPParsidate\Helper\WordPress; |
| 58 | use WPParsidate\Plugin\Install; |
| 59 | use WPParsidate\Plugin\Plugin; |
| 60 | use WPParsidate\Settings\Settings; |
| 61 | use WPParsidate\Widget\Widget; |
| 62 | |
| 63 | final class WP_Parsidate { |
| 64 | /** |
| 65 | * @var WP_Parsidate|null Class instance |
| 66 | */ |
| 67 | public static ?WP_Parsidate $instance = null; |
| 68 | |
| 69 | public function __construct() { |
| 70 | $this->define(); |
| 71 | $this->include(); |
| 72 | $this->instance(); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Define constant |
| 77 | * |
| 78 | * @return void |
| 79 | */ |
| 80 | private function define(): void { |
| 81 | if ( ! defined( 'WP_PARSI_KEY' ) ) { |
| 82 | define( 'WP_PARSI_KEY', 'wp_parsidate' ); |
| 83 | } |
| 84 | |
| 85 | if ( ! defined( 'WP_PARSI_KEY_SLUG' ) ) { |
| 86 | define( 'WP_PARSI_KEY_SLUG', 'wp-parsidate' ); |
| 87 | } |
| 88 | |
| 89 | if ( ! defined( 'WP_PARSI_KEY_CAP' ) ) { |
| 90 | define( 'WP_PARSI_KEY_CAP', 'WpParsiDate' ); |
| 91 | } |
| 92 | |
| 93 | if ( ! defined( 'WP_PARSI_ROOT' ) ) { |
| 94 | define( 'WP_PARSI_ROOT', __FILE__ ); |
| 95 | } |
| 96 | |
| 97 | if ( ! defined( 'WP_PARSI_DIR' ) ) { |
| 98 | define( 'WP_PARSI_DIR', plugin_dir_path( WP_PARSI_ROOT ) ); |
| 99 | } |
| 100 | |
| 101 | if ( ! defined( 'WP_PARSI_URL' ) ) { |
| 102 | define( 'WP_PARSI_URL', plugin_dir_url( WP_PARSI_ROOT ) ); |
| 103 | } |
| 104 | |
| 105 | if ( ! defined( 'WP_PARSI_CLASS_PREFIX' ) ) { |
| 106 | define( 'WP_PARSI_CLASS_PREFIX', 'wppd-' ); |
| 107 | } |
| 108 | |
| 109 | if ( ! defined( 'WP_PARSI_INPUT_PREFIX' ) ) { |
| 110 | define( 'WP_PARSI_INPUT_PREFIX', 'wp_parsidate_' ); |
| 111 | } |
| 112 | |
| 113 | add_action( 'init', static function () { |
| 114 | if ( ! function_exists( 'get_plugin_data' ) ) { |
| 115 | require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 116 | } |
| 117 | $pluginData = get_plugin_data( WP_PARSI_ROOT ); |
| 118 | define( 'WP_PARSI_VER', $pluginData['Version'] ); |
| 119 | }, 0 ); |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Include required files |
| 124 | * |
| 125 | * @return void |
| 126 | */ |
| 127 | private function include(): void { |
| 128 | require_once __DIR__ . '/vendor/autoload.php'; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Instant classes |
| 133 | * |
| 134 | * @return void |
| 135 | */ |
| 136 | private function instance(): void { |
| 137 | if ( ! defined( 'WP_PARSI_DEBUG_MODE' ) ) { |
| 138 | define( 'WP_PARSI_DEBUG_MODE', Settings::get( 'debug_mode', false ) ); |
| 139 | } |
| 140 | |
| 141 | new Admin(); |
| 142 | new Addons(); |
| 143 | |
| 144 | if ( WordPress::isMultilingualActive() && Settings::get( 'multilingual_support', false ) ) { |
| 145 | if ( |
| 146 | ( defined( 'ICL_LANGUAGE_CODE' ) && 'fa_IR' !== ICL_LANGUAGE_CODE ) || |
| 147 | ( function_exists( 'pll_current_language' ) && ( pll_current_language() !== false && pll_current_language() !== "fa" ) ) |
| 148 | ) { |
| 149 | return; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | new Plugin(); |
| 154 | new App(); |
| 155 | new Core(); |
| 156 | new Widget(); |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Returns an instance of WP_Parsidate class, makes instance if not exists |
| 161 | * |
| 162 | * @return WP_Parsidate Instance of WP_Parsidate |
| 163 | * @since 2.0 |
| 164 | */ |
| 165 | public static function getInstance(): ?self { |
| 166 | if ( self::$instance === null ) { |
| 167 | self::$instance = new WP_Parsidate(); |
| 168 | } |
| 169 | |
| 170 | return self::$instance; |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | WP_Parsidate::getInstance(); |
| 175 | register_activation_hook( __FILE__, array( Install::class, 'run' ) ); |
| 176 |