PluginProbe
پارسی دیت – Parsi Date / 4.0.1
پارسی دیت – Parsi Date v4.0.1
6.3 6.2.1 6.2 6.1 5.1.6 5.1.7 5.1.8 5.1.8.2 6.0 trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.0.0-alpha 2.1 2.1.1 2.1.2 2.1.3 2.1.5 All 49 releases
wp-parsidate / wp-parsidate.php

wp-parsidate.php in پارسی دیت – Parsi Date 4.0.1, at wp-parsidate.php

251 lines 6.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) || exit( 'No direct script access allowed' );
3
4 /**
5 * Plugin Name: WP-Parsidate
6 * Version: 4.0.1
7 * Plugin URI: https://wp-parsi.com/support/
8 * 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.
9 * Author: WP-Parsi Team
10 * Author URI: https://wp-parsi.com/
11 * Text Domain: wp-parsidate
12 * Domain Path: parsi-languages
13 * License: GPL3
14 *
15 * WP-Parsidate is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation, either version 2 of the License, or
18 * any later version.
19 *
20 * WP-Parsidate is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with WP-Parsidate.
27 *
28 *
29 * WordPress Parsi Package, Adds Persian language & Jalali date support to your blog
30 *
31 * Developers:
32 * Mobin Ghasempoor ( Senior programmer & Founder )
33 * Morteza Geransayeh ( Senior programmer & Manager )
34 * HamidReza Yazdani ( Programmer )
35 * Parsa Kafi ( Programmer )
36 * Alireza Dabiri Nejad ( Programmer )
37 * Ehsaan ( Programmer )
38 * Saeed Fard ( Analyst & Contributor )
39 * Farhan Nisi ( Contributor )
40 * Mostafa Soufi ( Contributor )
41 * Ali Aghdam ( Contributor )
42 * Kamran Khorsandi ( Contributor )
43 * Mehrshad Darzi ( Contributor )
44 * Nasser Rafie ( Contributor )
45 * Milad Nazari ( Contributor )
46 *
47 * @author Mobin Ghasempoor
48 * @author Morteza Geransayeh
49 * @link https://wp-parsi.com/
50 * @version 4.0.0
51 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU Public License v3.0
52 * @package WP-Parsidate
53 * @subpackage Core
54 */
55
56 /**
57 *
58 */
59 final class WP_Parsidate {
60 /**
61 * @var WP_Parsidate Class instance
62 */
63 public static $instance = null;
64
65 private function __construct() {
66 $this->define_const();
67 $this->setup_vars();
68 $this->include_files();
69
70 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'parsi_settings_link' ) );
71 add_action( 'widgets_init', array( $this, 'register_widget' ) );
72 add_action( 'admin_enqueue_scripts', array( $this, 'wpp_load_vazir_font_in_admin_area' ) );
73 }
74
75 /**
76 * Sets up constants for plugin
77 *
78 * @return void
79 * @since 2.0
80 */
81 private function define_const() {
82 if ( ! defined( 'WP_PARSI_ROOT' ) ) {
83 define( 'WP_PARSI_ROOT', __FILE__ );
84 }
85
86 if ( ! defined( 'WP_PARSI_DIR' ) ) {
87 define( 'WP_PARSI_DIR', plugin_dir_path( WP_PARSI_ROOT ) );
88 }
89
90 if ( ! defined( 'WP_PARSI_URL' ) ) {
91 define( 'WP_PARSI_URL', plugin_dir_url( WP_PARSI_ROOT ) );
92 }
93
94 if ( ! defined( 'WP_PARSI_VER' ) ) {
95 define( 'WP_PARSI_VER', '4.0.0' );
96 }
97 }
98
99 /**
100 * Sets up global variables
101 *
102 * @return void
103 * @since 2.0
104 */
105 private function setup_vars() {
106 global $persian_month_names;
107 $persian_month_names = array(
108 '',
109 'فروردین',
110 'اردیبهشت',
111 'خرداد',
112 'تیر',
113 '�
114 رداد',
115 'شهریور',
116 '�
117 هر',
118 'آبان',
119 'آذر',
120 'دی',
121 'به�
122 ن',
123 'اسفند'
124 );
125 }
126
127 /**
128 * Includes files for plugin
129 *
130 * @return void
131 * @since 2.0
132 */
133 public function include_files() {
134 require_once( WP_PARSI_DIR . 'includes/settings.php' );
135
136 global $wpp_settings;
137
138 $wpp_settings = wp_parsi_get_settings();
139 $files = array(
140 'parsidate',
141 'general',
142 'fixes-archive',
143 'fixes-permalinks',
144 'fixes-dates',
145 'fixes-misc',
146 'admin/styles-fix',
147 'admin/gutenberg-jalali-calendar',
148 'admin/lists-fix',
149 'admin/widgets',
150 'fixes-calendar',
151 'fixes-archives',
152 'widget/widget_archive',
153 'widget/widget_calendar'
154 );
155
156 if ( class_exists( 'WooCommerce' ) ) {
157 $files[] = 'plugins/woocommerce';
158 }
159
160 if ( class_exists( 'Easy_Digital_Downloads' ) ) {
161 $files[] = 'plugins/edd';
162 }
163
164 if ( class_exists( 'ACF' ) ) {
165 $files[] = 'plugins/acf';
166 }
167
168 $files[] = 'plugins/disable';
169
170 foreach ( $files as $file ) {
171 require_once( WP_PARSI_DIR . 'includes/' . $file . '.php' );
172 }
173
174 if ( get_locale() == 'fa_IR' ) {
175 load_textdomain( 'wp-parsidate', WP_PARSI_DIR . 'languages/fa_IR.mo' );
176 }
177 }
178
179 /**
180 * Returns an instance of WP_Parsidate class, makes instance if not exists
181 *
182 * @return WP_Parsidate Instance of WP_Parsidate
183 * @since 2.0
184 */
185 public static function get_instance() {
186 if ( self::$instance == null ) {
187 self::$instance = new WP_Parsidate();
188 }
189
190 return self::$instance;
191 }
192
193 /**
194 * Add Setting Link To Install Plugin
195 *
196 * @param array $links
197 *
198 * @return array
199 */
200 public static function parsi_settings_link( $links ) {
201 $settings_link = array( '<a href="' . menu_page_url( 'wp-parsi-settings', false ) . '">' . __( 'settings', 'wp-parsidate' ) . '</a>' );
202
203 return array_merge( $links, $settings_link );
204 }
205
206 /**
207 * Register Plugin Widgets
208 *
209 * @return boolean
210 * @since 2.0
211 */
212 public function register_widget() {
213 register_widget( 'parsidate_archive' );
214 register_widget( 'parsidate_calendar' );
215
216 return true;
217 }
218
219 /**
220 * Load vazir font in admin area
221 *
222 * @since 4.0.0
223 */
224 public function wpp_load_vazir_font_in_admin_area() {
225 if ( get_locale() !== 'fa_IR' ) {
226 return;
227 }
228
229 if( wpp_is_active( 'enable_fonts' ) ){
230
231 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || wpp_is_active( 'dev_mode' ) ? '' : '.min';
232
233 wp_enqueue_style( 'wpp-vazir-font', WP_PARSI_URL . "assets/css/vazir-font$suffix.css", null, WP_PARSI_VER, 'all' );
234
235 add_action( 'admin_head', array( $this, 'wpp_preload_vazir_fonts' ) );
236
237 }
238 }
239
240 /**
241 * Preload vazir font to achieve to high performance
242 *
243 * @since 4.0.0
244 */
245 public function wpp_preload_vazir_fonts() {
246 echo '<link rel="preload" href="' . WP_PARSI_URL . 'assets/fonts/Vazir-Regular.woff2" as="font" type="font/woff2" crossorigin>' . PHP_EOL .
247 '<link rel="preload" href="' . WP_PARSI_URL . 'assets/fonts/Vazir-Bold.woff2" as="font" type="font/woff2" crossorigin>' . PHP_EOL;
248 }
249 }
250
251 return WP_Parsidate::get_instance();