| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Highlighting Code Block |
| 4 |
* Plugin URI: https://wordpress.org/plugins/highlighting-code-block/ |
| 5 |
* Description: Add code block with syntax highlighting using prism.js. (Available for Gutenberg and Classic Editor) |
| 6 |
* Version: 1.0.9 |
| 7 |
* Author: LOOS WEB STUDIO |
| 8 |
* Author URI: https://loos-web-studio.com/ |
| 9 |
* License: GPL2 or later |
| 10 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 11 |
* Text Domain: loos-hcb |
| 12 |
*/ |
| 13 |
|
| 14 |
if ( !defined( 'ABSPATH' ) ) exit; |
| 15 |
|
| 16 |
/** |
| 17 |
* Be disabled ~PHP5.6. |
| 18 |
*/ |
| 19 |
$phpver = phpversion(); |
| 20 |
if ( (double) $phpver < 5.6 ) { |
| 21 |
add_action( 'admin_notices', function() { ?> |
| 22 |
<div class="notice notice-error is-dismissible"> |
| 23 |
<p> |
| 24 |
<b>[ Highlighting Code Block ]</b><br> |
| 25 |
This Plugin is available in PHP since version 5.6 ! <br> (Your PHP is ver. <?php echo phpversion(); ?> ) |
| 26 |
</p> |
| 27 |
</div> <?php |
| 28 |
} ); |
| 29 |
return; |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* 翻訳用のテキストドメインを定義 |
| 34 |
*/ |
| 35 |
if ( ! defined( 'LOOS_HCB_DOMAIN' ) ) { |
| 36 |
define( 'LOOS_HCB_DOMAIN', 'loos-hcb' ); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Defined HCB const. |
| 41 |
*/ |
| 42 |
if ( ! defined( 'LOOS_HCB_VERSION' ) ) { |
| 43 |
define( 'LOOS_HCB_VERSION', '1.0.9' ); |
| 44 |
// define( 'LOOS_HCB_VERSION', date('Ymdgis') ); //開発用 |
| 45 |
} |
| 46 |
if ( ! defined( 'LOOS_HCB_FILE' ) ) { |
| 47 |
define( 'LOOS_HCB_FILE', __FILE__ ); |
| 48 |
} |
| 49 |
if ( ! defined( 'LOOS_HCB_PATH' ) ) { |
| 50 |
define( 'LOOS_HCB_PATH', plugin_dir_path( __FILE__ ) ); |
| 51 |
} |
| 52 |
if ( ! defined( 'LOOS_HCB_BASENAME' ) ) { |
| 53 |
define( 'LOOS_HCB_BASENAME', plugin_basename( LOOS_HCB_FILE ) ); |
| 54 |
} |
| 55 |
if ( ! defined( 'LOOS_HCB_URL' ) ) { |
| 56 |
define( 'LOOS_HCB_URL', plugins_url( '', __FILE__ ) ); |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
/** |
| 61 |
* 翻訳ファイルを登録 |
| 62 |
*/ |
| 63 |
load_plugin_textdomain( LOOS_HCB_DOMAIN, false, basename( LOOS_HCB_PATH ) .'/languages' ); |
| 64 |
|
| 65 |
|
| 66 |
/** |
| 67 |
* Autoload Class files. |
| 68 |
*/ |
| 69 |
spl_autoload_register( function( $classname ) { |
| 70 |
$file = LOOS_HCB_PATH . 'class/'. mb_strtolower( $classname ) . '.php'; |
| 71 |
if ( file_exists( $file ) ) { |
| 72 |
require $file; |
| 73 |
} |
| 74 |
}); |
| 75 |
|
| 76 |
|
| 77 |
/** |
| 78 |
* Activation hooks. |
| 79 |
*/ |
| 80 |
register_activation_hook( LOOS_HCB_FILE, ['LOOS_HCB_Activation', 'plugin_activate'] ); |
| 81 |
register_deactivation_hook( LOOS_HCB_FILE, ['LOOS_HCB_Activation', 'plugin_deactivate'] ); |
| 82 |
register_uninstall_hook( LOOS_HCB_FILE, ['LOOS_HCB_Activation', 'plugin_uninstall'] ); |
| 83 |
|
| 84 |
|
| 85 |
/** |
| 86 |
* WP_Filesystem |
| 87 |
*/ |
| 88 |
require_once(ABSPATH.'wp-admin/includes/file.php'); |
| 89 |
|
| 90 |
|
| 91 |
/** |
| 92 |
* Init |
| 93 |
*/ |
| 94 |
new LOOS_HCB(); |
| 95 |
|