| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Gianism |
| 4 |
* Plugin URI: https://wordpress.org/extend/plugins/gianism/ |
| 5 |
* Description: Connect user accounts with major web services like Facebook, twitter, etc. Stand on the shoulders of giants! |
| 6 |
* Author: Takahashi_Fumiki |
| 7 |
* Version: 4.4.0 |
| 8 |
* PHP Version: 5.6.0 |
| 9 |
* Author URI: https://gianism.info |
| 10 |
* Text Domain: wp-gianism |
| 11 |
* Domain Path: /language/ |
| 12 |
* License: GPL2 or Later |
| 13 |
*/ |
| 14 |
|
| 15 |
/* |
| 16 |
Copyright 2010 Takahashi Fumiki (email : takahashi.fumiki@hametuha.co.jp) |
| 17 |
|
| 18 |
This program is free software; you can redistribute it and/or modify |
| 19 |
it under the terms of the GNU General Public License, version 2, as |
| 20 |
published by the Free Software Foundation. |
| 21 |
|
| 22 |
This program 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 this program; if not, write to the Free Software |
| 29 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 30 |
*/ |
| 31 |
|
| 32 |
// Don't allow plugin to be loaded directory. |
| 33 |
defined( 'ABSPATH' ) || die( 'Do not load directly.' ); |
| 34 |
|
| 35 |
// Get data from header. |
| 36 |
$info = get_file_data( __FILE__, array( |
| 37 |
'version' => 'Version', |
| 38 |
'php_version' => 'PHP Version', |
| 39 |
'text_domain' => 'Text Domain', |
| 40 |
) ); |
| 41 |
|
| 42 |
/** |
| 43 |
* Plugin version |
| 44 |
* |
| 45 |
* @const string |
| 46 |
*/ |
| 47 |
define( 'GIANISM_VERSION', $info['version'] ); |
| 48 |
|
| 49 |
/** |
| 50 |
* Domain for i18n |
| 51 |
* |
| 52 |
* @const string |
| 53 |
*/ |
| 54 |
define( 'GIANISM_DOMAIN', $info['text_domain'] ); |
| 55 |
|
| 56 |
/** |
| 57 |
* Gianism PHP Version |
| 58 |
* |
| 59 |
* @const string |
| 60 |
*/ |
| 61 |
define( 'GIANISM_PHP_VERSION', $info['php_version'] ); |
| 62 |
|
| 63 |
// Add action after plugins are loaded. |
| 64 |
add_action( 'plugins_loaded', 'gianism_setup_after_plugins_loaded', 11 ); |
| 65 |
|
| 66 |
/** |
| 67 |
* Start plugin |
| 68 |
* |
| 69 |
* @ignore |
| 70 |
*/ |
| 71 |
function gianism_setup_after_plugins_loaded() { |
| 72 |
// Add i18n for here for other plugins. |
| 73 |
load_plugin_textdomain( 'wp-gianism', false, basename( __DIR__ ) . '/language' ); |
| 74 |
// Check PHP version. |
| 75 |
try { |
| 76 |
if ( ! version_compare( phpversion(), GIANISM_PHP_VERSION, '>=' ) ) { |
| 77 |
// translators: %1$s is required PHP version, %2$s is current PHP version. |
| 78 |
throw new Exception( sprintf( __( '[Gianism] PHP <code>%1$s</code> is required, but your version is <code>%2$s</code>. So this plugin is still in silence. Please contact server administrator.', 'wp-gianism' ), GIANISM_PHP_VERSION, phpversion() ) ); |
| 79 |
} |
| 80 |
// Load composer. |
| 81 |
$auto_loader = dirname( __FILE__ ) . '/vendor/autoload.php'; |
| 82 |
if ( ! file_exists( $auto_loader ) ) { |
| 83 |
// translators: %s is file path, %2$s is composer command. |
| 84 |
throw new Exception( sprintf( esc_html( __( '[Gianism] missing composer\'s auto loader at %1$s. Did you run %2$s?', 'wp-gianism' ) ), dirname( __FILE__ ) . '/vendor/autoload.php', '<code>composer install</code>' ) ); |
| 85 |
} |
| 86 |
// Load auto loader. |
| 87 |
require $auto_loader; |
| 88 |
// Avoiding syntax error, call Bootstrap. |
| 89 |
if ( ! class_exists( 'Gianism\\Bootstrap' ) ) { |
| 90 |
throw new Exception( esc_html__( '[Gianism] Bootstrap file not found.', 'wp-gianism' ) ); |
| 91 |
} |
| 92 |
// Load functions. |
| 93 |
require __DIR__ . '/functions.php'; |
| 94 |
// Load all functions and hooks. |
| 95 |
foreach ( array( 'functions', 'hooks' ) as $dir ) { |
| 96 |
$dir_path = __DIR__ . '/' . $dir ; |
| 97 |
if ( ! is_dir( $dir_path ) ) { |
| 98 |
continue; |
| 99 |
} |
| 100 |
foreach ( scandir( $dir_path ) as $file ) { |
| 101 |
if ( preg_match( '#^[^._].*\.php$#u', $file ) ) { |
| 102 |
require $dir_path . '/' . $file; |
| 103 |
} |
| 104 |
} |
| 105 |
} |
| 106 |
if ( defined( 'GIANISM_SKIP_DEPRECATED' ) ) { |
| 107 |
require __DIR__ . '/functions-deprecated.php'; |
| 108 |
} |
| 109 |
// Call bootstrap. |
| 110 |
call_user_func( array( 'Gianism\\Bootstrap', 'init' ) ); |
| 111 |
} catch ( Exception $e ) { |
| 112 |
gianism_internal_error( $e->getMessage() ); |
| 113 |
add_action( 'admin_notices', 'gianism_internal_notice' ); |
| 114 |
} // End try(). |
| 115 |
} |
| 116 |
|
| 117 |
/** |
| 118 |
* Display admin error message. |
| 119 |
* |
| 120 |
* @since 3.1.0 |
| 121 |
* @ignore |
| 122 |
*/ |
| 123 |
function gianism_internal_notice() { |
| 124 |
printf( '<div class="error"><p>%s</p></div>', esc_html( gianism_internal_error() ) ); |
| 125 |
} |
| 126 |
|
| 127 |
/** |
| 128 |
* Error message holder. |
| 129 |
* |
| 130 |
* @since 3.1.0 |
| 131 |
* @ignore |
| 132 |
* @param string $message Message string which will be saved if not empty. |
| 133 |
* @return string |
| 134 |
*/ |
| 135 |
function gianism_internal_error( $message = '' ) { |
| 136 |
static $store = ''; |
| 137 |
if ( $message ) { |
| 138 |
$store = $message; |
| 139 |
} |
| 140 |
return $store; |
| 141 |
} |
| 142 |
|
| 143 |
/** |
| 144 |
* Get root directory. |
| 145 |
* |
| 146 |
* @since 4.2.0 |
| 147 |
* @return string |
| 148 |
*/ |
| 149 |
function gianism_root_dir() { |
| 150 |
return dirname( __FILE__ ); |
| 151 |
} |
| 152 |
|