wp-parsidate.php
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Name: WP-Parsidate |
| 4 | * Version: 2.3.3 |
| 5 | * Plugin URI: http://forum.wp-parsi.com/ |
| 6 | * 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. |
| 7 | * Author: WP-Parsi Team |
| 8 | * Author URI: http://wp-parsi.com/ |
| 9 | * Text Domain: wp-parsidate |
| 10 | * Domain Path: parsi-languages |
| 11 | * |
| 12 | * WordPress Parsi Package, Adds Persian language & Jalali date support to your blog |
| 13 | * |
| 14 | * Developers: |
| 15 | * Mobin Ghasempoor ( Senior programmer & Founder ) |
| 16 | * Morteza Geransayeh ( Senior programmer & Manager ) |
| 17 | * Ehsaan ( Programmer ) |
| 18 | * Farhan Nisi ( Programmer ) |
| 19 | * Parsa Kafi ( Programmer ) |
| 20 | * Saeed Fard ( Analyst ) |
| 21 | * |
| 22 | * @author Mobin Ghasempoor |
| 23 | * @author Morteza Geransayeh |
| 24 | * @author Farhan Nisi |
| 25 | * @author Ehsaan |
| 26 | * @link http://wp-parsi.com/ |
| 27 | * @version 2.2 |
| 28 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License v2.0 |
| 29 | * @package WP-Parsidate |
| 30 | * @subpackage Core |
| 31 | */ |
| 32 | |
| 33 | |
| 34 | if ( ! defined( 'ABSPATH' ) ) { |
| 35 | exit; |
| 36 | } // No direct access allowed |
| 37 | |
| 38 | final class WP_Parsidate { |
| 39 | /** |
| 40 | * @var WP_Parsidate Class instance |
| 41 | */ |
| 42 | public static $instance = null; |
| 43 | |
| 44 | private function __construct() { |
| 45 | $this->define_const(); |
| 46 | $this->setup_vars(); |
| 47 | $this->include_files(); |
| 48 | add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'parsi_settings_link' ) ); |
| 49 | add_action( 'widgets_init', array( $this, 'register_widget' ) ); |
| 50 | add_action( 'wp_dashboard_setup', 'wpp_add_dashboard_widgets' ); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Sets up constants for plugin |
| 55 | * |
| 56 | * @since 2.0 |
| 57 | * @return void |
| 58 | */ |
| 59 | private function define_const() { |
| 60 | if ( ! defined( 'WP_PARSI_ROOT' ) ) { |
| 61 | define( 'WP_PARSI_ROOT', __FILE__ ); |
| 62 | } |
| 63 | |
| 64 | if ( ! defined( 'WP_PARSI_DIR' ) ) { |
| 65 | define( 'WP_PARSI_DIR', plugin_dir_path( WP_PARSI_ROOT ) ); |
| 66 | } |
| 67 | |
| 68 | if ( ! defined( 'WP_PARSI_URL' ) ) { |
| 69 | define( 'WP_PARSI_URL', plugin_dir_url( WP_PARSI_ROOT ) ); |
| 70 | } |
| 71 | |
| 72 | if ( ! defined( 'WP_PARSI_VER' ) ) { |
| 73 | define( 'WP_PARSI_VER', '2.2' ); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Sets up global variables |
| 79 | * |
| 80 | * @since 2.0 |
| 81 | * @return void |
| 82 | */ |
| 83 | private function setup_vars() { |
| 84 | global $persian_month_names; |
| 85 | $persian_month_names = array( |
| 86 | '', |
| 87 | 'فروردین', |
| 88 | 'اردیبهشت', |
| 89 | 'خرداد', |
| 90 | 'تیر', |
| 91 | '� |
| 92 | رداد', |
| 93 | 'شهریور', |
| 94 | '� |
| 95 | هر', |
| 96 | 'آبان', |
| 97 | 'آذر', |
| 98 | 'دی', |
| 99 | 'به� |
| 100 | ن', |
| 101 | 'اسفند' |
| 102 | ); |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * Includes files for plugin |
| 107 | * |
| 108 | * @since 2.0 |
| 109 | * @return void |
| 110 | */ |
| 111 | public function include_files() { |
| 112 | require_once( WP_PARSI_DIR . 'includes/settings.php' ); |
| 113 | global $wpp_settings; |
| 114 | $wpp_settings = wp_parsi_get_settings(); |
| 115 | |
| 116 | $files = array( |
| 117 | 'parsidate', |
| 118 | 'general', |
| 119 | 'fixes-archive', |
| 120 | 'fixes-permalinks', |
| 121 | 'fixes-dates', |
| 122 | 'fixes-misc', |
| 123 | 'admin/styles-fix', |
| 124 | 'admin/lists-fix', |
| 125 | 'admin/widgets', |
| 126 | 'fixes-calendar', |
| 127 | 'fixes-archives', |
| 128 | 'plugins/woocommerce', |
| 129 | 'plugins/edd', |
| 130 | 'widget/widget_archive', |
| 131 | 'widget/widget_calendar' |
| 132 | ); |
| 133 | |
| 134 | foreach ( $files as $file ) { |
| 135 | require_once( WP_PARSI_DIR . 'includes/' . $file . '.php' ); |
| 136 | } |
| 137 | |
| 138 | if ( get_locale() == 'fa_IR' ) { |
| 139 | load_textdomain( 'wp-parsidate', WP_PARSI_DIR . 'languages/fa_IR.mo' ); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * Returns an instance of WP_Parsidate class, makes instance if not exists |
| 145 | * |
| 146 | * @since 2.0 |
| 147 | * @return WP_Parsidate Instance of WP_Parsidate |
| 148 | */ |
| 149 | public static function get_instance() { |
| 150 | if ( self::$instance == null ) { |
| 151 | self::$instance = new WP_Parsidate(); |
| 152 | } |
| 153 | |
| 154 | return self::$instance; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * Add Setting Link To Install Plugin |
| 159 | * |
| 160 | * @param array $links |
| 161 | * |
| 162 | * @return array |
| 163 | */ |
| 164 | public static function parsi_settings_link( $links ) { |
| 165 | $settings_link = array( '<a href="' . menu_page_url( 'wp-parsi-settings', false ) . '">' . __( 'settings', 'wp-parsidate' ) . '</a>' ); |
| 166 | |
| 167 | return array_merge( $links, $settings_link ); |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Register Plugin Widgets |
| 172 | * |
| 173 | * @since 2.0 |
| 174 | * @return boolean |
| 175 | */ |
| 176 | public function register_widget() { |
| 177 | register_widget( 'parsidate_archive' ); |
| 178 | register_widget( 'parsidate_calendar' ); |
| 179 | |
| 180 | return true; |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | return WP_Parsidate::get_instance(); |
| 185 |