array( 'abap' => 'ABAB', 'actionscript' => 'ActionScript', 'ada' => 'Ada', 'apacheconf' => 'Apache Configuration', 'apl' => 'APL', 'applescript' => 'AppleScript', 'asciidoc' => 'AsciiDoc', 'aspnet' => 'ASP.NET', 'autohotkey' => 'AutoHotkey', 'autoit' => 'AutoIt', 'bash' => 'Bash', 'basic' => 'BASIC', 'batch' => 'Batch', 'bison' => 'Bison', 'brainfuck' => 'Brainfuck', 'bro' => 'Bro', 'c' => 'C', 'clike' => 'C-Like', 'coffeescript' => 'CoffeeScript', 'core' => 'Core', 'cpp' => 'C++', 'crystal' => 'Crystal', 'csharp' => 'C#', 'css-extras' => 'CSS Extras', 'css' => 'CSS', 'd' => 'D', 'dart' => 'Dart', 'diff' => 'Diff', 'docker' => 'Docker', 'eiffel' => 'Eiffel', 'elixir' => 'Elixir', 'erlang' => 'Erlang', 'fortran' => 'Fortran', 'fsharp' => 'F#', 'gherkin' => 'Gherkin', 'git' => 'Git', 'glsl' => 'GLSL', 'go' => 'Go', 'graphql' => 'GraphQl', 'groovy' => 'Groovy', 'haml' => 'Haml', 'handlebars' => 'Handlebars', 'haskell' => 'Haskell', 'haxe' => 'Haxe', 'http' => 'HTTP', 'icon' => 'Icon', 'inform7' => 'Inform 7', 'ini' => 'Ini', 'j' => 'J', 'jade' => 'Jade', 'java' => 'Java', 'javascript' => 'JavaScript', 'json' => 'JSON', 'jsx' => 'JSX (React JSX)', 'julia' => 'Julia', 'keyman' => 'Keyman', 'kotlin' => 'Kotlin', 'latex' => 'LaTeX', 'less' => 'Less', 'livescript' => 'LiveScript', 'lolcode' => 'LOLCODE', 'lua' => 'Lua', 'makefile' => 'Makefile', 'markdown' => 'Markdown', 'markup' => 'Markup/HTML/XML', 'matlab' => 'MATLAB', 'mel' => 'MEL', 'mizar' => 'Mizar', 'monkey' => 'Monkey', 'nasm' => 'NASM', 'nginx' => 'nginx', 'nim' => 'Nim', 'nix' => 'Nix', 'nsis' => 'NSIS', 'objectivec' => 'Objective-C', 'ocaml' => 'OCaml', 'oz' => 'Oz', 'parigp' => 'PARI/GP', 'parser' => 'Parser', 'pascal' => 'Pascal', 'perl' => 'Perl', 'php-extras' => 'PHP Extras', 'php' => 'PHP', 'powershell' => 'PowerShell', 'processing' => 'Processing', 'prolog' => 'Prolog', 'properties' => 'Properties', 'protobuf' => 'Protocol Buffer', 'puppet' => 'Puppet', 'pure' => 'Pure', 'python' => 'Python', 'q' => 'Q', 'qore' => 'Qore', 'r' => 'R', 'rest' => 'ReST (reStructuredText)', 'rip' => 'Rip', 'roboconf' => 'Roboconf', 'ruby' => 'Ruby', 'rust' => 'Rust', 'sas' => 'SAS', 'sass' => 'Sass', 'scala' => 'Scala', 'scheme' => 'Scheme', 'scss' => 'Scss', 'smalltalk' => 'Smalltalk', 'smarty' => 'Smarty', 'sql' => 'SQL', 'stylus' => 'Stylus', 'swift' => 'Swift', 'tcl' => 'Tcl', 'textile' => 'Textile', 'twig' => 'Twig', 'typescript' => 'TypeScript', 'verilog' => 'Verilog', 'vhdl' => 'VHDL', 'vim' => 'Vim', 'wiki' => 'Wiki Markup', 'xojo' => 'Xojo (REAL Basic)', 'yaml' => 'YAML', 'adddarkplain' => 'Dark Plain', 'addlightplain' => 'Light Plain' ), 'themes' => array( 'default' => 'Default', 'coy' => 'Coy', 'dark' => 'Dark', 'funky' => 'Funky', 'okaidia' => 'Okaidia', 'solarizedlight' => 'Solarizedlight', 'tomorrow' => 'Tomorrow', 'twilight' => 'Twilight' ) ); private $data_options = array ( 'lang-used' => array ( 'core', 'clike', 'php', 'markup', 'css', 'javascript', 'sass', 'sql', 'adddarkplain', 'addlightplain' ), 'default-lang' => 'php', 'max-height' => '480', 'add-css' => 0, 'add-css-value' => '', 'theme' => 'default', 'gutter' => 1, 'start-number' => 1, 'auto-links' => 1, 'show-lang' => 0, 'show-hidden-char' => 0, 'class' => '', 'token' => '1470914799' ); private $options; private $options_phdata; private $admin_notices; public function __construct() { $this->admin_notices = new Aphph_Admin_Notices; $this->options = get_option( APHPH_OPTION, array() ); $this->options_phdata = get_option( APHPH_OPTION_PHDATA, array() ); register_activation_hook ( APHPH_PLUGIN_PATH . APHPH_DS . APHPH_PLUGIN_FILE_NAME, array($this, 'activate_plugin') ); add_action( 'admin_init', array( $this, 'page_init' ) ); add_action( 'admin_menu', array( $this, 'add_plugin_page' ) ); add_filter( 'plugin_action_links', array($this, 'action_link'), 10, 5); add_action( 'admin_enqueue_scripts', array($this, 'register_scripts') ); add_action( 'updated_option', array($this, 'build_files'), 10, 3); add_action( 'plugins_loaded', array($this, 'check_update') ); // AJAX add_action( 'wp_ajax_nopriv_aphph-dismiss-notice' , array( $this , 'ajax_no_priv' ) ); add_action( 'wp_ajax_aphph-dismiss-notice', array($this, 'ajax_dismiss_notice') ); } public function ajax_no_priv() { // echo 'xxx'; die; } // When the close button is clicked public function ajax_dismiss_notice() { $check = wp_verify_nonce($_POST['nonce'], 'aphph-admin-all'); if ($check) { $this->admin_notices->delete_notice($_POST['msg']); } wp_send_json_success( array( 'msg' => 'success', 'check' => $check ) ); } public function page_init() { register_setting( 'aphph_option_group', // Option group APHPH_OPTION, array ($this, 'submit_validation') ); } public function activate_plugin() { if (!$this->options) { update_option(APHPH_OPTION, $this->data_options); update_option(APHPH_OPTION_VERSION, APHPH_PLUGIN_VERSION); update_option(APHPH_OPTION_PHDATA, $this->default_param); add_action('wp_head', array($this, 'build_files')); } } public function check_update() { $plugin_option_version = get_option( APHPH_OPTION_VERSION, '0' ); if (version_compare(APHPH_PLUGIN_VERSION, $plugin_option_version) > 0) { update_option(APHPH_OPTION_VERSION, APHPH_PLUGIN_VERSION); update_option(APHPH_OPTION_PHDATA, $this->default_param); if (!$plugin_option_version || $plugin_option_version < 1.2) { $msg = 'APH PRISM HIGHLIGHTER v' . APHPH_PLUGIN_VERSION . ' Language added: Dark Plain and Light Plain'; $this->admin_notices->add_notice($msg, 'success', false, true); } } } public function register_scripts($hook) { if ($hook == 'settings_page_'.APHPH_PLUGIN_DIR_NAME) { wp_enqueue_style('aphph-style', APHPH_PLUGIN_URL . '/css/aphph-admin.css?rand='.time(), '', APHPH_PLUGIN_VERSION); wp_enqueue_style('aphph-icon', APHPH_PLUGIN_URL . '/css/icomoon/style.css?rand='.time(), '', APHPH_PLUGIN_VERSION); wp_enqueue_script('aphph-taboverride', APHPH_PLUGIN_URL . '/js/taboverride/taboverride.min.js', '', APHPH_PLUGIN_VERSION); wp_enqueue_script('aphph-prism-components', APHPH_PLUGIN_URL . '/includes/prism/components.js?rand='.time(), '', APHPH_PLUGIN_VERSION); wp_enqueue_script('aphph-admin', APHPH_PLUGIN_URL . '/js/aphph-admin.js?rand='.time(), 'aphph-prism-components', APHPH_PLUGIN_VERSION); } wp_enqueue_script('aphph-admin-all', APHPH_PLUGIN_URL . '/js/aphph-admin-all.js?rand='.time(), '', APHPH_PLUGIN_VERSION); wp_localize_script ( 'aphph-admin-all', 'aphph', array( 'nonce' => wp_create_nonce('aphph-admin-all'), 'ajaxurl' => admin_url('admin-ajax.php') ) ); } /** * Add Settings ling to plugin list Settings | Deactivate | Edit */ public function action_link($links, $file) { static $plugin; if (!isset($plugin)) $plugin = APHPH_PLUGIN_DIR_NAME . '/' . APHPH_PLUGIN_FILE_NAME; if ($plugin == $file) { $setting_link = 'Settings'; array_unshift($links, $setting_link); } return $links; } /** * Add options page */ public function add_plugin_page() { $page_title = 'APH Prism Highlighter Options'; $menu_title = 'Prism Highlighter'; $url = 'aph-prism-highlighter'; add_options_page( $page_title, $menu_title, 'manage_options', $url, array( $this, 'admin_setting_page' ) ); } public function admin_setting_page() { ?>
Default language in the code editor\'s drop down menu
'; // Other list of language, hidden, displayed when the language pack changed; echo ''; } public function option_theme_list() { $theme_list = $this->options_phdata['themes']; $options = ''; echo $options; } public function option_plugin_options() { $options = $this->options['options']; ?>
data_options; } else { foreach ($this->options as $key => $val) { if (!key_exists($key, $inputs)) { $inputs[$key] = 0; } } } return $inputs; } public function build_files() { $obj = new Aphph_Build; $obj->build_files(); } } ?>