array('compact-1' => 'Compact 1', 'compact-2' => 'Compact 2', 'common-1' => 'Common 1', 'full' => 'Full' ), 'lang-list' => array('compact-1' => array ( 'php' => 'PHP', 'xml' => 'XML / HTML', 'css' => 'CSS', 'javascript' => 'Javascript', 'sass' => 'SASS', 'sql' => 'SQL', 'plain' => 'Plain' ), 'compact-2' => array ('java' => 'Java', 'bash' => 'Bash', 'ruby' => 'Ruby', 'python' => 'Python', 'cpp' => 'C++', 'csharp' => 'C#', 'perl' => 'Perl', 'sql' => 'SQL', 'plain' => 'Plain' ), 'common-1' => array( 'php' => 'PHP', 'xml' => 'XML / HTML', 'css' => 'CSS', 'javascript' => 'Javascript', 'sass' => 'SASS', 'java' => 'Java', 'bash' => 'Bash', 'ruby' => 'Ruby', 'python' => 'Python', 'cpp' => 'C++', 'csharp' => 'C#', 'perl' => 'Perl', 'sql' => 'SQL', 'diff' => 'Diff', 'plain' => 'Plain' ), 'full' => array( 'php' => 'PHP', 'xml' => 'XML / HTML', 'css' => 'CSS', 'javascript' => 'Javascript', 'sass' => 'SASS', 'java' => 'Java', 'bash' => 'Bash', 'ruby' => 'Ruby', 'python' => 'Python', 'cpp' => 'C++', 'csharp' => 'C#', 'perl' => 'Perl', 'vb' => 'VB', 'poweshell' => 'Power Shell', 'typescript' => 'Typescript', 'tap' => 'Tap', 'swift' => 'Swift', 'scala' => 'Scala', 'javafx' => 'Java FX', 'haxe' => 'Haxe', 'groovy' => 'Groovy', 'erlang' => 'Erlang', 'delphi' => 'Delphi', 'coldfushion' => 'Coldfushion', 'as3' => 'Action Script 3', 'applescript' => 'Applescript', 'base' => 'Base', 'sql' => 'SQL', 'diff' => 'Diff', 'plain' => 'Plain' ), ), 'themes' => array( 'default' => 'Default', 'django' => 'Django', 'eclipse' => 'Eclipse', 'emacs' => 'EMACS', 'fadetogrey' => 'Fade to Grey', 'mdultra' => 'MDUltra', 'midnight' => 'Midnight', 'rdark' => 'RDark', 'swift' => 'Swift' ) ); /** * Default options, we use dash instead of undercore, because we'll use this * in the foreach loop at aphms-front.php */ private $data_options = array ('lang-pack' => 'compact-1', 'default-lang' => 'php', 'theme' => 'default', 'gutter' => 1, 'start-number' => 1, 'auto-links' => 1, 'collapse' => 0, 'class' => '', 'smart-tabs' => 1, 'tab-size' => 4, 'title' => '', 'font-size' => 'default' ); public function __construct() { $this->options = get_option( APHSH_OPTION, array() ); if (!$this->options) { update_option(APHSH_OPTION, $this->data_options); } register_activation_hook ( APHSH_PLUGIN_PATH . APHSH_DS . APHSH_PLUGIN_FILE_NAME, array($this, 'activate_plugin') ); add_action( 'admin_init', array( $this, 'page_init' ) ); add_action( 'admin_head', array( $this, 'print_style') ); 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, 'update_files'), 1); // add_action( 'admin_notices', array( $this, 'adminNotices' ), 1 ); } public function update_files() { $options = get_option(APHSH_OPTION); $font_size = $options['font-size'] == 'default' ? '1em !mportant' : $options['font-size'] . ' !important'; $file_path = APHSH_PLUGIN_PATH . APHSH_DS . 'includes' . APHSH_DS . 'syntaxhighlighter' . APHSH_DS . 'themes' . APHSH_DS . $options['theme'] . '.css'; if (file_exists($file_path)) { $css_file = file_get_contents($file_path); $css_file = preg_replace('/font-size:\s*[^;]*\;/', 'font-size: ' . $font_size . ';', $css_file); file_put_contents($file_path, $css_file, LOCK_EX); } } public function activate_plugin() { if (!$this->options) { update_option(APHSH_OPTION, $this->data_options); update_option(APHSH_OPTION_VERSION, APHSH_PLUGIN_VERSION); update_option(APHSH_OPTION_SHDATA, $this->default_param); } } public function register_scripts($hook) { if ($hook == 'settings_page_'.APHSH_PLUGIN_DIR_NAME) { wp_enqueue_style('aphsh-style', APHSH_PLUGIN_URL . '/css/aphsh-admin.css?rand='.time(), '', APHSH_PLUGIN_VERSION); wp_enqueue_script('aphsh-admin', APHSH_PLUGIN_URL . '/js/aphsh-admin.js?rand='.time(), '', APHSH_PLUGIN_VERSION); } } /** * Add Settings ling to plugin list Settings | Deactivate | Edit */ public function action_link($links, $file) { static $plugin; if (!isset($plugin)) $plugin = APHSH_PLUGIN_DIR_NAME . '/' . APHSH_PLUGIN_FILE_NAME; if ($plugin == $file) { $setting_link = 'Settings'; array_unshift($links, $setting_link); } return $links; } public function print_style() { echo ''; } /** * Add options page */ public function add_plugin_page() { $page_title = 'APH Syntax Highlighter Options'; $menu_title = 'Syntax Highlighter'; $url = 'aph-syntax-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->default_param['themes']; $options = ''; return $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; } } ?>