diff --git a/class/config.php b/class/config.php new file mode 100644 index 0000000..d996170 --- /dev/null +++ b/class/config.php @@ -0,0 +1,54 @@ +footnotes'; + + /** + * Html tag for the LOVE symbol. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var string + */ + const C_STR_LOVE_SYMBOL = ''; + + /** + * Short code to DON'T display the 'LOVE ME' slug on certain pages. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var string + */ + const C_STR_NO_LOVE_SLUG = '[[no footnotes: love]]'; +} \ No newline at end of file diff --git a/classes/convert.php b/class/convert.php similarity index 56% rename from classes/convert.php rename to class/convert.php index fc095f0..97ed2e5 100644 --- a/classes/convert.php +++ b/class/convert.php @@ -1,27 +1,29 @@ 0) { - $l_str_Return = chr($l_int_Offset + $l_int_StartingASCII); + $l_str_Return = chr($l_int_Offset + 64); } // add the origin letter - $l_str_Return .= chr($p_int_Value + $l_int_StartingASCII); + $l_str_Return .= chr($p_int_Value + 64); // return the latin character representing the integer - return $l_str_Return; + if ($p_bool_UpperCase) { + return strtoupper($l_str_Return); + } + return strtolower($l_str_Return); } /** - * converts a integer to a leading-0 integer + * Converts an integer to a leading-0 integer. + * + * @author Stefan Herndler * @since 1.0-gamma - * @param int $p_int_Value - * @return string + * @param int $p_int_Value Value/Index to be converted. + * @return string Value with a leading zero. */ private static function toArabicLeading($p_int_Value) { // add a leading 0 if number lower then 10 @@ -88,9 +91,11 @@ class MCI_Footnotes_Convert { } /** - * converts a arabic integer value into a romanic letter value + * Converts an integer to a romanic letter. + * + * @author Stefan Herndler * @since 1.0-gamma - * @param int $p_int_Value + * @param int $p_int_Value Value/Index to be converted. * @return string */ private static function toRomanic($p_int_Value) { @@ -127,15 +132,17 @@ class MCI_Footnotes_Convert { } /** - * converts a string depending on its value to a boolean + * Converts a string depending on its value to a boolean. + * + * @author Stefan Herndler * @since 1.0-beta - * @param string $p_str_Value - * @return bool + * @param string $p_str_Value String to be converted to boolean. + * @return bool Boolean representing the string. */ public static function toBool($p_str_Value) { - // convert string to lower-case to make it easier */ + // convert string to lower-case to make it easier $p_str_Value = strtolower($p_str_Value); - // check if string seems to contain a "true" value */ + // check if string seems to contain a "true" value switch ($p_str_Value) { case "checked": case "yes": @@ -144,14 +151,17 @@ class MCI_Footnotes_Convert { case "1": return true; } - // nothing found that says "true", so we return false */ + // nothing found that says "true", so we return false return false; } /** + * Get a html Array short code depending on Arrow-Array key index. + * + * @author Stefan Herndler * @since 1.3.2 - * @param int $p_int_Index [default: -1 = all arrows, otherwise the arrow with the specified index] - * @return array|string + * @param int $p_int_Index Index representing the Arrow. If empty all Arrows are specified. + * @return array|string Array of all Arrows if Index is empty otherwise html tag of a specific arrow. */ public static function getArrow($p_int_Index = -1) { // define all possible arrows @@ -167,6 +177,4 @@ class MCI_Footnotes_Convert { // return a single arrow return $l_arr_Arrows[$p_int_Index]; } -} // class MCI_Footnotes_Convert - -endif; \ No newline at end of file +} \ No newline at end of file diff --git a/class/dashboard/init.php b/class/dashboard/init.php new file mode 100644 index 0000000..fc418ed --- /dev/null +++ b/class/dashboard/init.php @@ -0,0 +1,213 @@ +a_arr_SubPageClasses[$l_obj_Class->getPriority()] = $l_obj_Class; + } + } + ksort($this->a_arr_SubPageClasses); + + // register hooks/actions + add_action('admin_init', array($this, 'initializeSettings')); + add_action('admin_menu', array($this, 'registerMainMenu')); + // register AJAX callbacks for Plugin information + add_action("wp_ajax_nopriv_footnotes_getPluginInfo", array($this, "getPluginMetaInformation")); + add_action("wp_ajax_footnotes_getPluginInfo", array($this, "getPluginMetaInformation")); + } + + /** + * Initializes all sub pages and registers the settings. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function initializeSettings() { + MCI_Footnotes_Settings::instance()->RegisterSettings(); + // iterate though each sub class of the layout engine and register their sections + /** @var MCI_Footnotes_LayoutEngine $l_obj_LayoutEngineSubClass */ + foreach($this->a_arr_SubPageClasses as $l_obj_LayoutEngineSubClass) { + $l_obj_LayoutEngineSubClass->registerSections(); + } + } + + /** + * Registers the new main menu for the WordPress dashboard. + * Registers all sub menu pages for the new main menu. + * + * @author Stefan Herndler + * @since 2.0.2 + * @see http://codex.wordpress.org/Function_Reference/add_menu_page + */ + public function registerMainMenu() { + global $menu; + // iterate through each main menu + foreach($menu as $l_arr_MainMenu) { + // iterate through each main menu attribute + foreach($l_arr_MainMenu as $l_str_Attribute) { + // main menu already added, append sub pages and stop + if ($l_str_Attribute == self::C_STR_MAIN_MENU_SLUG) { + $this->registerSubPages(); + return; + } + } + } + + // add a new main menu page to the WordPress dashboard + add_menu_page( + self::C_STR_MAIN_MENU_TITLE, // page title + self::C_STR_MAIN_MENU_TITLE, // menu title + 'manage_options', // capability + self::C_STR_MAIN_MENU_SLUG, // menu slug + array($this, "displayOtherPlugins"), // function + '', // icon url + 81 // position + ); + $this->registerSubPages(); + } + + /** + * Registers all SubPages for this Plugin. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + private function registerSubPages() { + // first registered sub menu page MUST NOT contain a unique slug suffix + // iterate though each sub class of the layout engine and register their sub page + /** @var MCI_Footnotes_LayoutEngine $l_obj_LayoutEngineSubClass */ + foreach($this->a_arr_SubPageClasses as $l_obj_LayoutEngineSubClass) { + $l_obj_LayoutEngineSubClass->registerSubPage(); + } + } + + /** + * Displays other Plugins from the developers. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function displayOtherPlugins() { + $l_arr_Plugins = array( + array("name" => "identity", "title" => "Identity"), + array("name" => "google-keyword-suggest", "title" => "Google Keyword Suggest"), + array("name" => "competition", "title" => "competition"), + array("name" => "formscontact", "title" => "/forms.contact"), + array("name" => "footnotes", "title" => "Footnotes") + ); + + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "other-plugins"); + + echo sprintf("

%s


", __('Take a look on other Plugins we have developed.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); + + echo '
'; + // iterate through each Plugin + foreach($l_arr_Plugins as $l_arr_PluginInfo) { + // replace Plugin information + $l_obj_Template->replace( + array( + "name" => $l_arr_PluginInfo["name"], + "title" => $l_arr_PluginInfo["title"] + ) + ); + // display Plugin + echo $l_obj_Template->getContent(); + // reload template + $l_obj_Template->reload(); + } + echo '
'; + } + + /** + * AJAX call. returns a JSON string containing meta information about a specific WordPress Plugin. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function getPluginMetaInformation() { + // get plugin internal name from POST data + $l_str_PluginName = array_key_exists("plugin", $_POST) ? $_POST["plugin"] : null; + if (empty($l_str_PluginName)) { + echo json_encode(array("error" => "Plugin name invalid.")); + exit; + } + $l_str_Url = "https://api.wordpress.org/plugins/info/1.0/".$l_str_PluginName.".json"; + // call URL and collect data + $l_arr_Response = wp_remote_get($l_str_Url); + // check if response is valid + if (is_wp_error($l_arr_Response)) { + echo json_encode(array("error" => "Can't get Plugin information.")); + exit; + } + // get the body of the response + $l_str_Response = $l_arr_Response["body"]; + // get plugin object + $l_arr_Plugin = json_decode($l_str_Response, true); + + // return Plugin information as JSON encoded string + echo json_encode( + array( + "error" => "", + "PluginImage" => "", + "PluginDescription" => html_entity_decode($l_arr_Plugin["short_description"]), + "PluginUrl" => $l_arr_Plugin["homepage"], + "PluginVersion" => $l_arr_Plugin["version"] + ) + ); + exit; + } +} \ No newline at end of file diff --git a/class/dashboard/layout.php b/class/dashboard/layout.php new file mode 100644 index 0000000..ba1259d --- /dev/null +++ b/class/dashboard/layout.php @@ -0,0 +1,449 @@ + MCI_Footnotes_Config::C_STR_PLUGIN_NAME . "-" . $p_str_ID, "title" => $p_str_Title, "submit" => $p_bool_hasSubmitButton, "container" => $p_int_SettingsContainerIndex); + } + + /** + * Returns an array describing a meta box. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_SectionID Parent Section ID. + * @param string $p_str_ID Unique ID suffix. + * @param string $p_str_Title Title for the meta box. + * @param string $p_str_CallbackFunctionName Class method name for callback. + * @return array meta box description to be able to append a meta box to the output. + */ + protected function addMetaBox($p_str_SectionID, $p_str_ID, $p_str_Title, $p_str_CallbackFunctionName) { + return array("parent" => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . "-" . $p_str_SectionID, "id" => $p_str_ID, "title" => $p_str_Title, "callback" => $p_str_CallbackFunctionName); + } + + /** + * Registers a sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function registerSubPage() { + global $submenu; + // iterate through each sub menu + foreach($submenu as $l_arr_SubMenu) { + // iterate through each sub menu attribute + foreach($l_arr_SubMenu as $l_str_Attribute) { + // sub menu already added, stop + if ($l_str_Attribute == MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug()) { + return; + } + } + } + + $this->a_str_SubPageHook = add_submenu_page( + MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG, // parent slug + $this->getSubPageTitle(), // page title + $this->getSubPageTitle(), // menu title + 'manage_options', // capability + MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug(), // menu slug + array($this, 'displayContent') // function + ); + } + + /** + * Registers all sections for a sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function registerSections() { + // iterate through each section + foreach($this->getSections() as $l_arr_Section) { + // append tab to the tab-array + $this->a_arr_Sections[$l_arr_Section["id"]] = $l_arr_Section; + add_settings_section( + $l_arr_Section["id"], // unique id + "", //$l_arr_Section["title"], // title + array($this, 'Description'), // callback function for the description + $l_arr_Section["id"] // parent sub page slug + ); + $this->registerMetaBoxes($l_arr_Section["id"]); + } + } + + /** + * Registers all Meta boxes for a sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_ParentID Parent section unique id. + */ + private function registerMetaBoxes($p_str_ParentID) { + // iterate through each meta box + foreach($this->getMetaBoxes() as $l_arr_MetaBox) { + if ($l_arr_MetaBox["parent"] != $p_str_ParentID) { + continue; + } + add_meta_box( + $p_str_ParentID. "-" . $l_arr_MetaBox["id"], // unique id + $l_arr_MetaBox["title"], // meta box title + array($this, $l_arr_MetaBox["callback"]), // callback function to display (echo) the content + $p_str_ParentID, // post type = parent section id + 'main' // context + ); + } + } + + /** + * Append javascript and css files for specific sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + private function appendScripts() { + // add jQuery to the sub menu page + wp_enqueue_script('jquery'); + // enable meta boxes layout and close functionality + wp_enqueue_script('postbox'); + // register stylesheet + wp_register_style('mci-footnotes-admin-styles', plugins_url('../../css/settings.css', __FILE__)); + // add stylesheet to the output + wp_enqueue_style('mci-footnotes-admin-styles'); + } + + /** + * Displays the content of specific sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function displayContent() { + // register and enqueue scripts and styling + $this->appendScripts(); + // get current section + reset($this->a_arr_Sections); + $l_str_ActiveSectionID = isset($_GET['t']) ? $_GET['t'] : key($this->a_arr_Sections); + $l_arr_ActiveSection = $this->a_arr_Sections[$l_str_ActiveSectionID]; + // store settings + $l_bool_SettingsUpdated = false; + if (array_key_exists("save-settings", $_POST)) { + if ($_POST["save-settings"] == "save") { + $l_bool_SettingsUpdated = $this->saveSettings(); + } + } + + // display all sections and highlight the active section + echo '
'; + echo '
'; + + if ($l_bool_SettingsUpdated) { + echo sprintf('
%s
', __("Settings saved", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); + } + + // form to submit the active section + echo '
'; + settings_fields($l_arr_ActiveSection["container"]); + echo ''; + // outputs the settings field of the active section + do_settings_sections($l_arr_ActiveSection["id"]); + do_meta_boxes($l_arr_ActiveSection["id"], 'main', NULL); + + // add submit button to active section if defined + if ($l_arr_ActiveSection["submit"]) { + submit_button(); + } + // close the form to submit data + echo '
'; + // close container for the settings page + echo '
'; + // output special javascript for the expand/collapse function of the meta boxes + echo ''; + } + + /** + * Save all Plugin settings. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return bool + */ + private function saveSettings() { + // get only Footnotes settings + $l_arr_Settings = array(); + foreach($_POST as $l_str_SettingsName => $l_str_Value) { + if (substr($l_str_SettingsName, 0, 8) == "footnote") { + $l_arr_Settings[$l_str_SettingsName] = $l_str_Value; + } + } + // get current section + reset($this->a_arr_Sections); + $l_str_ActiveSectionID = isset($_GET['t']) ? $_GET['t'] : key($this->a_arr_Sections); + $l_arr_ActiveSection = $this->a_arr_Sections[$l_str_ActiveSectionID]; + // update settings + return MCI_Footnotes_Settings::instance()->saveOptions($l_arr_ActiveSection["container"], $l_arr_Settings); + } + + /** + * Output the Description of a section. May be overwritten in any section. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function Description() { + // default no description will be displayed + } + + /** + * Loads specific setting and returns an array with the keys [id, name, value]. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_SettingKeyName Settings Array key name. + * @return array Contains Settings ID, Settings Name and Settings Value. + */ + protected function LoadSetting($p_str_SettingKeyName) { + // get current section + reset($this->a_arr_Sections); + $l_str_ActiveSectionID = isset($_GET['t']) ? $_GET['t'] : key($this->a_arr_Sections); + $l_arr_ActiveSection = $this->a_arr_Sections[$l_str_ActiveSectionID]; + + $p_arr_Return = array(); + $p_arr_Return["id"] = sprintf('%s', $p_str_SettingKeyName); + //$p_arr_Return["name"] = sprintf('%s[%s]', MCI_Footnotes_Settings::instance()->getContainer($l_arr_ActiveSection["container"]), $p_str_SettingKeyName); + $p_arr_Return["name"] = sprintf('%s', $p_str_SettingKeyName); + $p_arr_Return["value"] = esc_attr(MCI_Footnotes_Settings::instance()->get($p_str_SettingKeyName)); + return $p_arr_Return; + } + + /** + * Returns a line break to start a new line. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + */ + protected function addNewline() { + return '
'; + } + + /** + * Returns a line break to have a space between two lines. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + */ + protected function addLineSpace() { + return '

'; + } + + /** + * Returns a simple text inside html text. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_Text Message to be surrounded with simple html tag (span). + * @return string + */ + protected function addText($p_str_Text) { + return sprintf('%s', $p_str_Text); + } + + /** + * Returns the html tag for an input/select label. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_SettingName Name of the Settings key to connect the Label with the input/select field. + * @param string $p_str_Caption Label caption. + * @return string + */ + protected function addLabel($p_str_SettingName, $p_str_Caption) { + if (empty($p_str_Caption)) { + return ""; + } + return sprintf('', $p_str_SettingName, $p_str_Caption); + } + + /** + * Returns the html tag for an input [type = text]. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_SettingName Name of the Settings key to pre load the input field. + * @param int $p_str_MaxLength Maximum length of the input, default 999 characters. + * @param bool $p_bool_Readonly Set the input to be read only, default false. + * @param bool $p_bool_Hidden Set the input to be hidden, default false. + * @return string + */ + protected function addTextBox($p_str_SettingName, $p_str_MaxLength = 999, $p_bool_Readonly = false, $p_bool_Hidden = false) { + $l_str_Style = ""; + // collect data for given settings field + $l_arr_Data = $this->LoadSetting($p_str_SettingName); + if ($p_bool_Hidden) { + $l_str_Style .= 'display:none;'; + } + return sprintf('', + $l_arr_Data["name"], $l_arr_Data["id"], $p_str_MaxLength, + $l_str_Style, $l_arr_Data["value"], $p_bool_Readonly ? 'readonly="readonly"' : ''); + } + + /** + * Returns the html tag for an input [type = checkbox]. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_SettingName Name of the Settings key to pre load the input field. + * @return string + */ + protected function addCheckbox($p_str_SettingName) { + // collect data for given settings field + $l_arr_Data = $this->LoadSetting($p_str_SettingName); + return sprintf('', + $l_arr_Data["name"], $l_arr_Data["id"], + MCI_Footnotes_Convert::toBool($l_arr_Data["value"]) ? 'checked="checked"' : ''); + } + + /** + * Returns the html tag for a select box. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_SettingName Name of the Settings key to pre select the current value. + * @param array $p_arr_Options Possible options to be selected. + * @return string + */ + protected function addSelectBox($p_str_SettingName, $p_arr_Options) { + // collect data for given settings field + $l_arr_Data = $this->LoadSetting($p_str_SettingName); + $l_str_Options = ""; + + /* loop through all array keys */ + foreach ($p_arr_Options as $l_str_Value => $l_str_Caption) { + $l_str_Options .= sprintf('', + $l_str_Value, + $l_arr_Data["value"] == $l_str_Value ? "selected" : "", + $l_str_Caption); + } + return sprintf('', + $l_arr_Data["name"], $l_arr_Data["id"], $l_str_Options); + } + + /** + * Returns the html tag for a text area. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_SettingName Name of the Settings key to pre fill the text area. + * @return string + */ + protected function addTextArea($p_str_SettingName) { + // collect data for given settings field + $l_arr_Data = $this->LoadSetting($p_str_SettingName); + return sprintf('', + $l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"]); + } + +} // end of class \ No newline at end of file diff --git a/class/dashboard/subpage-diagnostics.php b/class/dashboard/subpage-diagnostics.php new file mode 100644 index 0000000..b8ba7fd --- /dev/null +++ b/class/dashboard/subpage-diagnostics.php @@ -0,0 +1,130 @@ +addSection("diagnostics", __("Diagnostics", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), null, false) + ); + } + + /** + * Returns an array of all registered meta boxes for each section of the sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return array + */ + protected function getMetaBoxes() { + return array( + $this->addMetaBox("diagnostics", "diagnostics", __("Displays information about the web server, PHP and WordPress", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Diagnostics") + ); + } + + /** + * Displays a diagnostics about the web server, php and WordPress. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function Diagnostics() { + global $wp_version; + $l_str_PhpExtensions = ""; + // iterate through each PHP extension + foreach (get_loaded_extensions() as $l_int_Index => $l_str_Extension) { + if ($l_int_Index > 0) { + $l_str_PhpExtensions .= ' | '; + } + $l_str_PhpExtensions .= $l_str_Extension . ' ' . phpversion($l_str_Extension); + } + $l_str_WordPressPlugins = ""; + // iterate through each installed WordPress Plugin + foreach (get_plugins() as $l_arr_Plugin) { + $l_str_WordPressPlugins .= ''; + $l_str_WordPressPlugins .= '' . $l_arr_Plugin["Name"] . ''; + $l_str_WordPressPlugins .= '' . $l_arr_Plugin["Version"] . ' [' . $l_arr_Plugin["PluginURI"] . ']' . ''; + $l_str_WordPressPlugins .= ''; + } + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "diagnostics"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-server" => __("Server name", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "server" => $_SERVER["SERVER_NAME"], + + "label-php" => __("PHP version", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "php" => phpversion(), + + "label-max-execution-time" => __("Max execution time", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "max-execution-time" => ini_get('max_execution_time') . ' ' . __('seconds', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + + "label-memory-limit" => __("Memory limit", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "memory-limit" => ini_get('memory_limit'), + + "label-php-extensions" => __("PHP extensions", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "php-extensions" => $l_str_PhpExtensions, + + "label-wordpress" => __("WordPress version", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "wordpress" => $wp_version, + + "plugins" => $l_str_WordPressPlugins + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } +} \ No newline at end of file diff --git a/class/dashboard/subpage-main.php b/class/dashboard/subpage-main.php new file mode 100644 index 0000000..c426233 --- /dev/null +++ b/class/dashboard/subpage-main.php @@ -0,0 +1,393 @@ +addSection("settings", __("Settings", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 0, true), + $this->addSection("customize", __("Customize", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), 1, true), + $this->addSection("how-to", __("How to", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), null, false) + ); + } + + /** + * Returns an array of all registered meta boxes for each section of the sub page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return array + */ + protected function getMetaBoxes() { + return array( + $this->addMetaBox("settings", "reference-container", __("References Container", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "ReferenceContainer"), + $this->addMetaBox("settings", "styling", sprintf(__("%s styling", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME), "Styling"), + $this->addMetaBox("settings", "love", MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME . ' ' . MCI_Footnotes_Config::C_STR_LOVE_SYMBOL, "Love"), + $this->addMetaBox("settings", "other", __("Other", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Other"), + + $this->addMetaBox("customize", "superscript", __("Superscript layout", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Superscript"), + $this->addMetaBox("customize", "hyperlink-arrow", __("Hyperlink symbol in the Reference container", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "HyperlinkArrow"), + $this->addMetaBox("customize", "custom-css", __("Add custom CSS to the public page", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "CustomCSS"), + + $this->addMetaBox("how-to", "help", __("Brief introduction in how to use the plugin", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Help"), + $this->addMetaBox("how-to", "donate", __("Help us to improve our Plugin", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Donate") + ); + } + + /** + * Displays all settings for the reference container. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function ReferenceContainer() { + // options for the positioning of the reference container + $l_arr_Positions = array( + "footer" => __("in the footer", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "post_end" => __("at the end of the post", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "widget" => __("in the widget area", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) + ); + + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "settings-reference-container"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-name" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME, __("References label", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "name" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME), + + "label-collapse" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE, __("Collapse references by default", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "collapse" => $this->addCheckbox(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE), + + "label-position" => $this->addLabel(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, __("Where shall the reference container appear", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "position" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION, $l_arr_Positions) + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays all settings for the footnotes styling. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function Styling() { + // define some space for the output + $l_str_Space = "     "; + // options for the combination of identical footnotes + $l_arr_CombineIdentical = array( + "yes" => __("Yes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "no" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) + ); + // options for the start of the footnotes short code + $l_arr_ShortCodeStart = array( + "((" => "((", + "" => htmlspecialchars(""), + "[ref]" => "[ref]", + "userdefined" => __('user defined', MCI_Footnotes_Config::C_STR_PLUGIN_NAME) + ); + // options for the end of the footnotes short code + $l_arr_ShortCodeEnd = array( + "))" => "))", + "" => htmlspecialchars(""), + "[/ref]" => "[/ref]", + "userdefined" => __('user defined', MCI_Footnotes_Config::C_STR_PLUGIN_NAME) + ); + // options for the counter style of the footnotes + $l_arr_CounterStyle = array( + "arabic_plain" => __("Arabic Numbers - Plain", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "1, 2, 3, 4, 5, ...", + "arabic_leading" => __("Arabic Numbers - Leading 0", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "01, 02, 03, 04, 05, ...", + "latin_low" => __("Latin Character - lower case", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "a, b, c, d, e, ...", + "latin_high" => __("Latin Character - upper case", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "A, B, C, D, E, ...", + "romanic" => __("Roman Numerals", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_str_Space . "I, II, III, IV, V, ..." + ); + + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "settings-styling"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-identical" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES, __("Combine identical footnotes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "identical" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES, $l_arr_CombineIdentical), + + "label-short-code-start" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, __("Footnote tag starts with", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "short-code-start" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, $l_arr_ShortCodeStart), + + "label-short-code-end" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END, __("and ends with", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "short-code-end" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END, $l_arr_ShortCodeEnd), + + "label-short-code-start-user" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED, ""), + "short-code-start-user" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED), + + "label-short-code-end-user" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED, ""), + "short-code-end-user" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED), + + "label-counter-style" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE, __("Counter style", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "counter-style" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE, $l_arr_CounterStyle), + + "short-code-start-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START, + "short-code-end-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END, + "short-code-start-user-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED, + "short-code-end-user-id" => MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED, + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays all settings for 'I love Footnotes'. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function Love() { + // options for the positioning of the reference container + $l_arr_Love = array( + "text-1" => sprintf(__('I %s %s', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_LOVE_SYMBOL, MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME), + "text-2" => sprintf(__('this site uses the awesome %s Plugin', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME), + "text-3" => sprintf(__('extra smooth %s', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME), + "random" => __('random text', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "no" => sprintf(__("Don't display a %s %s text in my footer.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME, MCI_Footnotes_Config::C_STR_LOVE_SYMBOL) + ); + + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "settings-love"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-love" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE, sprintf(__("Tell the world you're using %s", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME)), + "love" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE, $l_arr_Love), + + "label-no-love" => $this->addText(sprintf(__("Don't tell the world you're using %s on specific pages by adding the following short code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME)), + "no-love" => $this->addText(MCI_Footnotes_Config::C_STR_NO_LOVE_SLUG) + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays all settings that are not grouped in special meta boxes. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function Other() { + // options for the Footnotes to be replaced in excerpt + $l_arr_Excerpt = array( + "yes" => __("Yes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "no" => __("No", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) + ); + + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "settings-other"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-excerpt" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_IN_EXCERPT, __("Allow footnotes on Summarized Posts", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "excerpt" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_IN_EXCERPT, $l_arr_Excerpt) + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays all settings for the footnotes Superscript. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function Superscript() { + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "customize-superscript"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-before" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE, __("Before Footnotes index", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "before" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE), + + "label-after" => $this->addLabel(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER, __("After Footnotes index", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "after" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER) + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays all settings for the hyperlink arrow. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function HyperlinkArrow() { + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "customize-hyperlink-arrow"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-symbol" => $this->addLabel(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW, __("Hyperlink symbol", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "symbol" => $this->addSelectBox(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW, MCI_Footnotes_Convert::getArrow()), + + "label-user-defined" => $this->addLabel(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW_USER_DEFINED, __("or enter a user defined symbol", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "user-defined" => $this->addTextBox(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW_USER_DEFINED), + "comment" => __("if set it overrides the hyperlink symbol above", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays the custom css box. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function CustomCSS() { + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "customize-css"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-css" => $this->addLabel(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS, __("Add custom CSS", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + "css" => $this->addTextArea(MCI_Footnotes_Settings::C_STR_CUSTOM_CSS), + + "headline" => $this->addText(__("Available CSS classes to customize the footnotes and the reference container", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + + "label-class-1" => ".footnote_plugin_tooltip_text", + "class-1" => $this->addText(__("inline footnotes", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + + "label-class-2" => ".footnote_tooltip", + "class-2" => $this->addText(__("inline footnotes, mouse over highlight box", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + + "label-class-3" => ".footnote_plugin_index", + "class-3" => $this->addText(__("reference container footnotes index", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + + "label-class-4" => ".footnote_plugin_link", + "class-4" => $this->addText(__("reference container footnotes linked arrow", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)), + + "label-class-5" => ".footnote_plugin_text", + "class-5" => $this->addText(__("reference container footnotes text", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)) + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays a short introduction of the Plugin. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function Help() { + global $g_obj_MCI_Footnotes; + // load footnotes starting and end tag + $l_arr_Footnote_StartingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START); + $l_arr_Footnote_EndingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END); + + if ($l_arr_Footnote_StartingTag["value"] == "userdefined" || $l_arr_Footnote_EndingTag["value"] == "userdefined") { + // load user defined starting and end tag + $l_arr_Footnote_StartingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED); + $l_arr_Footnote_EndingTag = $this->LoadSetting(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED); + } + $l_str_Example = "Hello" . $l_arr_Footnote_StartingTag["value"] . __("example string", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . $l_arr_Footnote_EndingTag["value"] . " World!"; + + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "how-to-help"); + // replace all placeholders + $l_obj_Template->replace( + array( + "label-start" => __("Start your footnote with the following short code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "start" => $l_arr_Footnote_StartingTag["value"], + + "label-end" => __("...and end your footnote with this short code:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "end" => $l_arr_Footnote_EndingTag["value"], + + "example-code" => $l_str_Example, + "example-string" => __("will be displayed as:", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), + "example" => $g_obj_MCI_Footnotes->a_obj_Task->exec($l_str_Example, true), + + "information" => sprintf(__("For further information please check out our %ssupport forum%s on WordPress.org.", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), '', '') + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } + + /** + * Displays all Donate button to support the developers. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function Donate() { + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "how-to-donate"); + // replace all placeholders + $l_obj_Template->replace( + array( + "caption" => __('Donate now',MCI_Footnotes_Config::C_STR_PLUGIN_NAME) + ) + ); + // display template with replaced placeholders + echo $l_obj_Template->getContent(); + } +} \ No newline at end of file diff --git a/class/hooks.php b/class/hooks.php new file mode 100644 index 0000000..598a179 --- /dev/null +++ b/class/hooks.php @@ -0,0 +1,88 @@ +ClearAll(); + } + + /** + * Add Links to the Plugin in the "installed Plugins" page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param array $p_arr_Links Current Links. + * @param string $p_str_PluginFileName Plugins init file name. + * @return array + */ + public static function PluginLinks($p_arr_Links, $p_str_PluginFileName) { + // append link to the WordPress Plugin page + $p_arr_Links[] = sprintf('%s', __('Support', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); + // append link to the Settings page + $p_arr_Links[] = sprintf('%s', admin_url('options-general.php?page=mfmmf-footnotes'), __('Settings', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); + // append link to the PlayPal Donate function + $p_arr_Links[] = sprintf('%s', __('Donate', MCI_Footnotes_Config::C_STR_PLUGIN_NAME)); + // return new links + return $p_arr_Links; + } +} \ No newline at end of file diff --git a/class/init.php b/class/init.php new file mode 100644 index 0000000..c3fa01e --- /dev/null +++ b/class/init.php @@ -0,0 +1,116 @@ +initializeWidgets(); + // initialize the Plugin Dashboard + $this->initializeDashboard(); + // initialize the Plugin Task + $this->initializeTask(); + + // Register all Public Stylesheets + add_action('init', array($this, 'registerPublicStyling')); + // Register all Public Scripts + add_action('init', array($this, 'registerPublicScripts')); + // Enqueue all Public Stylesheets + add_action('wp_enqueue_scripts', array($this, 'registerPublicStyling')); + // Enqueue all Public Scripts + add_action('wp_enqueue_scripts', array($this, 'registerPublicScripts')); + } + + /** + * Initializes all Widgets of the Plugin. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + private function initializeWidgets() { + add_action('widgets_init', create_function('', 'return register_widget("MCI_Footnotes_Widget_ReferenceContainer");')); + } + + /** + * Initializes the Dashboard of the Plugin and loads them. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + private function initializeDashboard() { + new MCI_Footnotes_Layout_Init(); + } + + /** + * Initializes the Plugin Task and registers the Task hooks. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + private function initializeTask() { + $this->a_obj_Task = new MCI_Footnotes_Task(); + $this->a_obj_Task->registerHooks(); + } + + /** + * Registers and enqueue scripts to the public pages. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function registerPublicScripts() { + // add the jQuery plugin (already registered by WordPress) + wp_enqueue_script('jquery'); + wp_enqueue_script('mci_footnotes_js_jquery_tools', plugins_url('../js/jquery.tools.min.js', __FILE__), array()); + } + + /** + * Registers and enqueue stylesheets to the public pages. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function registerPublicStyling() { + wp_register_style('mci_footnotes_css_general', plugins_url('../css/footnotes.css', __FILE__)); + wp_register_style('mci_footnotes_css_tooltip', plugins_url('../css/tooltip.css', __FILE__)); + wp_register_style('mci_footnotes_css_reference_container', plugins_url('../css/reference_container.css', __FILE__)); + + wp_enqueue_style('mci_footnotes_css_general'); + wp_enqueue_style('mci_footnotes_css_tooltip'); + wp_enqueue_style('mci_footnotes_css_reference_container'); + } +} \ No newline at end of file diff --git a/class/language.php b/class/language.php new file mode 100644 index 0000000..ba582dd --- /dev/null +++ b/class/language.php @@ -0,0 +1,68 @@ + array( + self::C_STR_REFERENCE_CONTAINER_NAME => 'References', + self::C_BOOL_REFERENCE_CONTAINER_COLLAPSE => '', + self::C_STR_REFERENCE_CONTAINER_POSITION => 'post_end', + self::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES => 'yes', + self::C_STR_FOOTNOTES_SHORT_CODE_START => '((', + self::C_STR_FOOTNOTES_SHORT_CODE_END => '))', + self::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED => '', + self::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED => '', + self::C_STR_FOOTNOTES_COUNTER_STYLE => 'arabic_plain', + self::C_STR_FOOTNOTES_LOVE => 'no', + self::C_BOOL_FOOTNOTES_IN_EXCERPT => 'yes' + ), + "footnotes_storage_custom" => array( + self::C_STR_FOOTNOTES_STYLING_BEFORE => '', + self::C_STR_FOOTNOTES_STYLING_AFTER => ')', + self::C_STR_HYPERLINK_ARROW => '↑', + self::C_STR_HYPERLINK_ARROW_USER_DEFINED => '', + self::C_STR_CUSTOM_CSS => '' + ) + ); + + /** + * Contains all Settings from each Settings container as soon as this class is initialized. + * + * @author Stefan Herndler + * @since 1.5.0 + * @var array + */ + private $a_arr_Settings = array(); + + /** + * Class Constructor. Loads all Settings from each WordPress Settings container. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + private function __construct() { + $this->loadAll(); + } + + /** + * Returns a singleton of this class. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return MCI_Footnotes_Settings + */ + public static function instance() { + // no instance defined yet, load it + if (self::$a_obj_Instance === null) { + self::$a_obj_Instance = new self(); + } + // return a singleton of this class + return self::$a_obj_Instance; + } + + /** + * Returns the name of a specified Settings Container. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param int $p_int_Index Settings Container Array Key Index. + * @return string Settings Container name. + */ + public function getContainer($p_int_Index) { + return $this->a_arr_Container[$p_int_Index]; + } + + /** + * Loads all Settings from each Settings container. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + private function loadAll() { + // clear current settings + $this->a_arr_Settings = array(); + for ($i = 0; $i < count($this->a_arr_Container); $i++) { + // load settings + $this->a_arr_Settings = array_merge($this->a_arr_Settings, $this->Load($i)); + } + } + + /** + * Loads all Settings from specified Settings Container. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param int $p_int_Index Settings Container Array Key Index. + * @return array Settings loaded from Container of Default Settings if Settings Container is empty (first usage). + */ + private function Load($p_int_Index) { + // load all settings from container + $l_arr_Options = get_option($this->getContainer($p_int_Index)); + // load all default settings + $l_arr_Default = $this->a_arr_Default[$this->getContainer($p_int_Index)]; + + // no settings found, set them to their default value + if (empty($l_arr_Options)) { + return $l_arr_Default; + } + // iterate through all available settings ( = default values) + foreach($l_arr_Default as $l_str_Key => $l_str_Value) { + // available setting not found in the container + if (!array_key_exists($l_str_Key, $l_arr_Options)) { + // define the setting with its default value + $l_arr_Options[$l_str_Key] = $l_str_Value; + } + } + // iterate through each setting in the container + foreach($l_arr_Options as $l_str_Key => $l_str_Value) { + // remove all whitespace at the beginning and end of a setting + $l_str_Value = trim($l_str_Value); + // write the sanitized value back to the setting container + $l_arr_Options[$l_str_Key] = $l_str_Value; + } + // return settings loaded from Container + return $l_arr_Options; + } + + /** + * Updates a whole Settings container. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param int $p_int_Index Index of the Settings container. + * @param array $p_arr_newValues new Settings. + * @return bool + */ + public function saveOptions($p_int_Index, $p_arr_newValues) { + if (update_option($this->getContainer($p_int_Index), $p_arr_newValues)) { + $this->loadAll(); + return true; + } + return false; + } + + /** + * Returns the value of specified Settings name. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_Key Settings Array Key name. + * @return mixed Value of the Setting on Success or Null in Settings name is invalid. + */ + public function get($p_str_Key) { + return array_key_exists($p_str_Key, $this->a_arr_Settings) ? $this->a_arr_Settings[$p_str_Key] : null; + } + + /** + * Deletes each Settings Container and loads the default values for each Settings Container. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function ClearAll() { + // iterate through each Settings Container + for ($i = 0; $i < count($this->a_arr_Container); $i++) { + // delete the settings container + delete_option($this->getContainer($i)); + } + // set settings back to the default values + $this->a_arr_Settings = $this->a_arr_Default; + } + + /** + * Register all Settings Container for the Plugin Settings Page in the Dashboard. + * Settings Container Label will be the same as the Settings Container Name. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function RegisterSettings() { + // register all settings + for ($i = 0; $i < count($this->a_arr_Container); $i++) { + register_setting($this->getContainer($i), $this->getContainer($i)); + } + } +} \ No newline at end of file diff --git a/class/task.php b/class/task.php new file mode 100644 index 0000000..d3e84a9 --- /dev/null +++ b/class/task.php @@ -0,0 +1,355 @@ +get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "footer") { + add_action('get_footer', array($this, "Footer")); + } + + // append the love and share me slug to the footer + add_action('wp_footer', array($this, "Love")); + + // replace footnotes in the content of the page/post + add_filter('the_content', array($this, "Content")); + + // search for footnotes in the excerpt only if enabled + if (MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_IN_EXCERPT))) { + add_filter('the_excerpt', array($this, "Excerpt")); + } + + // replace footnotes in the content of a widget + add_filter('widget_text', array($this, "WidgetText")); + } + + /** + * Outputs the custom css to the header of the public page. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function Header() { + ?> + + ReferenceContainer(); + } + + /** + * Displays the 'LOVE FOOTNOTES' slug if enabled. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function Love() { + // get setting for love and share this plugin + $l_str_LoveMeIndex = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_LOVE); + // check if the admin allows to add a link to the footer + if (empty($l_str_LoveMeIndex) || strtolower($l_str_LoveMeIndex) == "no" || !self::$a_bool_AllowLoveMe) { + return; + } + // set a hyperlink to the word "footnotes" in the Love slug + $l_str_LinkedName = sprintf('%s',MCI_Footnotes_Config::C_STR_PLUGIN_PUBLIC_NAME); + // get random love me text + if (strtolower($l_str_LoveMeIndex) == "random") { + $l_str_LoveMeIndex = "text-" . rand(1,3); + } + switch ($l_str_LoveMeIndex) { + case "text-1": + $l_str_LoveMeText = sprintf(__('I %s %s', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), MCI_Footnotes_Config::C_STR_LOVE_SYMBOL, $l_str_LinkedName); + break; + case "text-2": + $l_str_LoveMeText = sprintf(__('this site uses the awesome %s Plugin', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), $l_str_LinkedName); + break; + case "text-3": + default: + $l_str_LoveMeText = sprintf(__('extra smooth %s', MCI_Footnotes_Config::C_STR_PLUGIN_NAME), $l_str_LinkedName); + break; + } + echo sprintf('
%s
', $l_str_LoveMeText); + } + + /** + * Replaces footnotes in the content of the current page/post. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_Content Page/Post content. + * @return string Content with replaced footnotes. + */ + public function Content($p_str_Content) { + // appends the reference container if set to "post_end" + return $this->exec($p_str_Content, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "post_end" ? true : false); + } + + /** + * Replaces footnotes in the excerpt of the current page/post. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_Content Page/Post content. + * @return string Content with replaced footnotes. + */ + public function Excerpt($p_str_Content) { + return $this->exec($p_str_Content, false); + } + + /** + * Replaces footnotes in the content of the current widget. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_Content Widget content. + * @return string Content with replaced footnotes. + */ + public function WidgetText($p_str_Content) { + // appends the reference container if set to "post_end" + return $this->exec($p_str_Content, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "post_end" ? true : false); + } + + + /** + * Replaces all footnotes that occur in the given content. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_Content Any string that may contain footnotes to be replaced. + * @param bool $p_bool_OutputReferences Appends the Reference Container to the output if set to true, default true. + * @return string + */ + public function exec($p_str_Content, $p_bool_OutputReferences = true) { + // replace all footnotes in the content, settings are converted to html characters + $p_str_Content = $this->search($p_str_Content, true); + // replace all footnotes in the content, settings are NOT converted to html characters + $p_str_Content = $this->search($p_str_Content, false); + + // append the reference container + if ($p_bool_OutputReferences) { + $p_str_Content = $p_str_Content . $this->ReferenceContainer(); + } + + // take a look if the LOVE ME slug should NOT be displayed on this page/post, remove the short code if found + if (strpos($p_str_Content, MCI_Footnotes_Config::C_STR_NO_LOVE_SLUG) !== false) { + self::$a_bool_AllowLoveMe = false; + $p_str_Content = str_replace(MCI_Footnotes_Config::C_STR_NO_LOVE_SLUG, "", $p_str_Content); + } + // return the content with replaced footnotes and optional reference container append + return $p_str_Content; + } + + /** + * Replaces all footnotes in the given content and appends them to the static property. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param string $p_str_Content Content to be searched for footnotes. + * @param bool $p_bool_ConvertHtmlChars html encode settings, default true. + * @return string + */ + public function search($p_str_Content, $p_bool_ConvertHtmlChars = true) { + // contains the index for the next footnote on this page + $l_int_FootnoteIndex = count(self::$a_arr_Footnotes) + 1; + // contains the starting position for the lookup of a footnote + $l_int_PosStart = 0; + // get start and end tag for the footnotes short code + $l_str_StartingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START); + $l_str_EndingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END); + if ($l_str_StartingTag == "userdefined" || $l_str_EndingTag == "userdefined") { + $l_str_StartingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED); + $l_str_EndingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED); + } + // decode html special chars + if ($p_bool_ConvertHtmlChars) { + $l_str_StartingTag = htmlspecialchars($l_str_StartingTag); + $l_str_EndingTag = htmlspecialchars($l_str_EndingTag); + } + // if footnotes short code is empty, return the content without changes + if (empty($l_str_StartingTag) || empty($l_str_EndingTag)) { + return $p_str_Content; + } + + // load template file + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "footnote"); + + // search footnotes short codes in the content + do { + // get first occurrence of the footnote short code [start] + $l_int_PosStart = strpos($p_str_Content, $l_str_StartingTag, $l_int_PosStart); + // no short code found, stop here + if ($l_int_PosStart === false) { + break; + } + // get first occurrence of a footnote short code [end] + $l_int_PosEnd = strpos($p_str_Content, $l_str_EndingTag, $l_int_PosStart); + // no short code found, stop here + if ($l_int_PosEnd === false) { + break; + } + // calculate the length of the footnote + $l_int_Length = $l_int_PosEnd - $l_int_PosStart; + // get footnote text + $l_str_FootnoteText = substr($p_str_Content, $l_int_PosStart + strlen($l_str_StartingTag), $l_int_Length - strlen($l_str_StartingTag)); + // fill the footnotes template + $l_obj_Template->replace( + array( + "index" => MCI_Footnotes_Convert::Index($l_int_FootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE)), + "text" => $l_str_FootnoteText, + "before" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_BEFORE), + "after" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_STYLING_AFTER) + ) + ); + // replace the footnote with the template + $p_str_Content = substr_replace($p_str_Content, $l_obj_Template->getContent(), $l_int_PosStart, $l_int_Length + strlen($l_str_EndingTag)); + // reset the template + $l_obj_Template->reload(); + // add footnote only if not empty + if (!empty($l_str_FootnoteText)) { + // set footnote to the output box at the end + self::$a_arr_Footnotes[] = $l_str_FootnoteText; + // increase footnote index + $l_int_FootnoteIndex++; + } + // add offset to the new starting position + $l_int_PosStart += $l_int_Length + strlen($l_str_EndingTag); + } while (true); + + // return content + return $p_str_Content; + } + + /** + * Generates the reference container. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + */ + public function ReferenceContainer() { + // no footnotes has been replaced on this page + if (empty(self::$a_arr_Footnotes)) { + return ""; + } + // get html arrow + $l_str_Arrow = MCI_Footnotes_Convert::getArrow(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW)); + // set html arrow to the first one if invalid index defined + if (is_array($l_str_Arrow)) { + $l_str_Arrow = MCI_Footnotes_Convert::getArrow(0); + } + // get user defined arrow + $l_str_ArrowUserDefined = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_HYPERLINK_ARROW_USER_DEFINED); + if (!empty($l_str_ArrowUserDefined)) { + $l_str_Arrow = $l_str_ArrowUserDefined; + } + + // load template file + $l_str_Body = ""; + $l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container-body"); + + // loop through all footnotes found in the page + for ($l_str_Index = 0; $l_str_Index < count(self::$a_arr_Footnotes); $l_str_Index++) { + // get footnote text + $l_str_FootnoteText = self::$a_arr_Footnotes[$l_str_Index]; + // if footnote is empty, get to the next one + if (empty($l_str_FootnoteText)) { + continue; + } + // get footnote index + $l_str_FirstFootnoteIndex = ($l_str_Index + 1); + $l_str_FootnoteIndex = MCI_Footnotes_Convert::Index(($l_str_Index + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE)); + + // check if it isn't the last footnote in the array + if ($l_str_FirstFootnoteIndex < count(self::$a_arr_Footnotes) && MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_COMBINE_IDENTICAL_FOOTNOTES))) { + // get all footnotes that I haven't passed yet + for ($l_str_CheckIndex = $l_str_FirstFootnoteIndex; $l_str_CheckIndex < count(self::$a_arr_Footnotes); $l_str_CheckIndex++) { + // check if a further footnote is the same as the actual one + if ($l_str_FootnoteText == self::$a_arr_Footnotes[$l_str_CheckIndex]) { + // set the further footnote as empty so it won't be displayed later + self::$a_arr_Footnotes[$l_str_CheckIndex] = ""; + // add the footnote index to the actual index + $l_str_FootnoteIndex .= ", " . MCI_Footnotes_Convert::Index(($l_str_CheckIndex + 1), MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE)); + } + } + } + // replace all placeholders in the template + $l_obj_Template->replace( + array( + "index" => $l_str_FootnoteIndex, + "index-int" => MCI_Footnotes_Convert::Index($l_str_FirstFootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE)), + "arrow" => $l_str_Arrow, + "text" => $l_str_FootnoteText + ) + ); + $l_str_Body .= $l_obj_Template->getContent(); + $l_obj_Template->reload(); + } + + // load template file + $l_obj_TemplateContainer = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_PUBLIC, "reference-container"); + $l_obj_TemplateContainer->replace( + array( + "label" => MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_NAME), + "buttons" => MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE)) ? '   [ + ]' : '', + "id" => "footnote_references_container", + "class" => MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE)) ? 'footnote_hide_box' : '', + "content" => $l_str_Body + ) + ); + + // free all found footnotes if reference container will be displayed + self::$a_arr_Footnotes = array(); + return $l_obj_TemplateContainer->getContent(); + } +} \ No newline at end of file diff --git a/class/template.php b/class/template.php new file mode 100644 index 0000000..993cb88 --- /dev/null +++ b/class/template.php @@ -0,0 +1,127 @@ +a_str_OriginalContent = str_replace("\n", "", file_get_contents($l_str_TemplateFile)); + $this->a_str_OriginalContent = str_replace("\r", "", $this->a_str_OriginalContent); + $this->reload(); + } + + /** + * Replace all placeholders specified in array. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param array $p_arr_Placeholders Placeholders (key = placeholder, value = value). + * @return bool True on Success, False if Placeholders invalid. + */ + public function replace($p_arr_Placeholders) { + // no placeholders set + if (empty($p_arr_Placeholders)) { + return false; + } + // template content is empty + if (empty($this->a_str_ReplacedContent)) { + return false; + } + // iterate through each placeholder and replace it with its value + foreach($p_arr_Placeholders as $l_str_Placeholder => $l_str_Value) { + $this->a_str_ReplacedContent = str_replace("[[" . $l_str_Placeholder . "]]", $l_str_Value, $this->a_str_ReplacedContent); + } + // success + return true; + } + + /** + * Reloads the original content of the template file. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function reload() { + $this->a_str_ReplacedContent = $this->a_str_OriginalContent; + } + + /** + * Returns the content of the template file with replaced placeholders. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string Template content with replaced placeholders. + */ + public function getContent() { + return $this->a_str_ReplacedContent; + } + +} // end of class \ No newline at end of file diff --git a/class/widgets/base.php b/class/widgets/base.php new file mode 100644 index 0000000..a9a3616 --- /dev/null +++ b/class/widgets/base.php @@ -0,0 +1,75 @@ + echo the Widget Content + * **public function form($instance)** -> echo the Settings of the Widget + * + * @author Stefan Herndler + * @since 1.5.0 + */ +abstract class MCI_Footnotes_WidgetBase extends WP_Widget { + + /** + * Returns an unique ID as string used for the Widget Base ID. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + */ + abstract protected function getID(); + + /** + * Returns the Public name of child Widget to be displayed in the Configuration page. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + */ + abstract protected function getName(); + + /** + * Returns the Description of the child widget. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return string + */ + abstract protected function getDescription(); + + /** + * Returns the width of the Widget. Default width is 250 pixel. + * + * @author Stefan Herndler + * @since 1.5.0 + * @return int + */ + protected function getWidgetWidth() { + return 250; + } + + /** + * Class Constructor. Registers the child Widget to WordPress. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public function __construct() { + $l_arr_WidgetOptions = array("classname" => __CLASS__, "description" => $this->getDescription()); + $l_arr_ControlOptions = array("id_base" => strtolower($this->getID()), "width" => $this->getWidgetWidth()); + // registers the Widget + $this->WP_Widget( + strtolower($this->getID()), // unique ID for the widget, has to be lowercase + $this->getName(), // Plugin name to be displayed + $l_arr_WidgetOptions, // Optional Widget Options + $l_arr_ControlOptions // Optional Widget Control Options + ); + } +} \ No newline at end of file diff --git a/class/widgets/reference-container.php b/class/widgets/reference-container.php new file mode 100644 index 0000000..58a5747 --- /dev/null +++ b/class/widgets/reference-container.php @@ -0,0 +1,79 @@ +get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "widget") { + echo $g_obj_MCI_Footnotes->a_obj_Task->ReferenceContainer(); + } + } +} \ No newline at end of file diff --git a/class/wysiwyg.php b/class/wysiwyg.php new file mode 100644 index 0000000..87d8b55 --- /dev/null +++ b/class/wysiwyg.php @@ -0,0 +1,78 @@ +getContent(); + } + + /** + * Includes the Plugins WYSIWYG editor script. + * + * @author Stefan Herndler + * @since 1.5.0 + * @param array $p_arr_Plugins Scripts to be included to the editor. + * @return array + */ + public static function includeScripts($p_arr_Plugins) { + $p_arr_Plugins[MCI_Footnotes_Config::C_STR_PLUGIN_NAME] = plugins_url('/../js/wysiwyg-editor.js', __FILE__); + return $p_arr_Plugins; + } + + /** + * AJAX Callback function when the Footnotes Button is clicked. Either in the Plain text or Visual editor. + * Returns an JSON encoded array with the Footnotes start and end short code. + * + * @author Stefan Herndler + * @since 1.5.0 + */ + public static function ajaxCallback() { + // get start and end tag for the footnotes short code + $l_str_StartingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START); + $l_str_EndingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END); + if ($l_str_StartingTag == "userdefined" || $l_str_EndingTag == "userdefined") { + $l_str_StartingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED); + $l_str_EndingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED); + } + echo json_encode(array("start" => $l_str_StartingTag, "end" => $l_str_EndingTag)); + exit; + } +} \ No newline at end of file diff --git a/classes/admin.php b/classes/admin.php deleted file mode 100644 index 7f8dacd..0000000 --- a/classes/admin.php +++ /dev/null @@ -1,402 +0,0 @@ -a_arr_SettingsTabs); - // load tab 'custom' - require_once(dirname( __FILE__ ) . "/tab_custom.php"); - new MCI_Footnotes_Tab_Custom($this->a_arr_SettingsTabs); - // load tab 'how to' - require_once(dirname( __FILE__ ) . "/tab_howto.php"); - new MCI_Footnotes_Tab_HowTo($this->a_arr_SettingsTabs); - // load tab 'diagnostics' - require_once(dirname( __FILE__ ) . "/tab_diagnostics.php"); - new MCI_Footnotes_Tab_Diagnostics($this->a_arr_SettingsTabs); - } - - /** - * sets the plugin's title for the admins settings menu - * called in class constructor @ admin_menu - * @since 1.0 - */ - public function RegisterMenu() { - // current user needs the permission to update plugins for further access - if (!current_user_can('update_plugins')) { - return; - } - // Add a new sub menu to the standard Settings panel - $this->a_str_Pagehook = add_options_page( - FOOTNOTES_PLUGIN_PUBLIC_NAME, - FOOTNOTES_PLUGIN_PUBLIC_NAME, - 'administrator', - FOOTNOTES_SETTINGS_PAGE_ID, - array($this, 'DisplaySettings') - ); - } - - /** - * Plugin Options page rendering goes here, checks - * for active tab and replaces key with the related - * settings key. Uses the plugin_options_tabs method - * to render the tabs. - * @since 1.0 - */ - public function DisplaySettings() { - // load stylesheets and scripts - $this->LoadScriptsAndStylesheets(); - - // gets active tab, or if nothing set the "general" tab will be set to active - self::$a_str_ActiveTab = isset($_GET['tab']) ? $_GET['tab'] : FOOTNOTES_SETTINGS_TAB_GENERAL; - // outputs all tabs - echo '
'; - echo ''; - - // outputs a form with the content of the current active tab - echo '
'; - wp_nonce_field('update-options'); - settings_fields(self::$a_str_ActiveTab); - // outputs the settings field of the current active tab - do_settings_sections(self::$a_str_ActiveTab); - do_meta_boxes(self::$a_str_ActiveTab, 'main', NULL); - // adds a submit button to the current page - if (self::$a_str_ActiveTab != FOOTNOTES_SETTINGS_TAB_HOWTO && self::$a_str_ActiveTab != FOOTNOTES_SETTINGS_TAB_DIAGNOSTICS) { - submit_button(); - } - echo '
'; - echo '
'; - - // output settings page specific javascript code - $this->OutputJavascript(); - } - - /** - * register and loads css and javascript files for settings - * @since 1.3 - */ - private function LoadScriptsAndStylesheets() { - // register settings stylesheet - wp_register_style('footnote_settings_style', plugins_url('../css/settings.css', __FILE__)); - // add settings stylesheet - wp_enqueue_style('footnote_settings_style'); - - // Needed to allow meta box layout and close functionality - wp_enqueue_script('postbox'); - } - - /** - * outputs page specific javascript code - * @since 1.0.7 - */ - private function OutputJavascript() { - ?> - - - a_arr_Options)) { - $this->a_arr_Options = MCI_Footnotes_getOptions(true); - } - $p_arr_Return = array(); - $p_arr_Return["id"] = $this->getFieldID($p_str_FieldID); - $p_arr_Return["name"] = $this->getFieldName($p_str_FieldID); - $p_arr_Return["value"] = esc_attr($this->getFieldValue($p_str_FieldID)); - return $p_arr_Return; - } - - /** - * access settings field by name - * @since 1.0 - * @param string $p_str_FieldName - * @return string - */ - protected function getFieldName($p_str_FieldName) { - // general setting - if (MCI_Footnotes_Admin::$a_str_ActiveTab == FOOTNOTES_SETTINGS_TAB_GENERAL) { - return sprintf('%s[%s]', FOOTNOTES_SETTINGS_CONTAINER, $p_str_FieldName); - // custom setting - } else if (MCI_Footnotes_Admin::$a_str_ActiveTab == FOOTNOTES_SETTINGS_TAB_CUSTOM) { - return sprintf('%s[%s]', FOOTNOTES_SETTINGS_CONTAINER_CUSTOM, $p_str_FieldName); - } - // undefined - return sprintf('%s[%s]', FOOTNOTES_SETTINGS_CONTAINER, $p_str_FieldName); - } - - /** - * access settings field by id - * @since 1.0 - * @param string $p_str_FieldID - * @return string - */ - protected function getFieldID($p_str_FieldID) { - return sprintf( '%s', $p_str_FieldID ); - } - - /** - * get settings field value - * @since 1.0 - * @param string $p_str_Key - * @return string - */ - protected function getFieldValue($p_str_Key) { - return $this->a_arr_Options[$p_str_Key]; - } - - /** - * outputs a break to have a new line - * @since 1.0.7 - */ - public function AddNewline() { - echo '

'; - } - - /** - * outputs a simple text - * @param string $p_str_Text - * @since 1.1.1 - */ - public function AddText($p_str_Text) { - echo '' . $p_str_Text . ''; - } - - /** - * outputs a simple text with some highlight - * @param string $p_str_Text+ - * @return string - * @since 1.1.1 - */ - public function Highlight($p_str_Text) { - return '' . $p_str_Text . ''; - } - - /** - * outputs a label for a specific input/select box - * @param string $p_str_SettingsID - * @param string $p_str_Caption - * @param string $p_str_Styling - * @since 1.0.7 - */ - public function AddLabel($p_str_SettingsID, $p_str_Caption, $p_str_Styling = "") { - // add styling tag if styling is set - if (!empty($p_str_Styling)) { - $p_str_Styling = ' style="' . $p_str_Styling . '"'; - } - echo ''; - } - - /** - * outputs a input type=text - * @param string $p_str_SettingsID [id of the settings field] - * @param string $p_str_ClassName [css class name] - * @param int $p_str_MaxLength [max length for the input value] - * @param bool $p_bool_Readonly [input is readonly] in version 1.1.1 - * @param bool $p_bool_Hidden [input is hidden by default] in version 1.1.2 - * @since 1.0-beta - * removed optional parameter for a label in version 1.0.7 - */ - public function AddTextbox($p_str_SettingsID, $p_str_ClassName = "", $p_str_MaxLength = 0, $p_bool_Readonly = false, $p_bool_Hidden = false) { - // collect data for given settings field - $l_arr_Data = $this->LoadSetting($p_str_SettingsID); - - // if input shall have a css class, add the style tag for it - if (!empty($p_str_ClassName)) { - $p_str_ClassName = 'class="' . $p_str_ClassName . '"'; - } - // optional add a max length to the input field - if (!empty($p_str_MaxLength)) { - $p_str_MaxLength = ' maxlength="' . $p_str_MaxLength . '"'; - } - - if ($p_bool_Readonly) { - $p_bool_Readonly = ' readonly="readonly"'; - } - if ($p_bool_Hidden) { - $p_bool_Hidden = ' style="display:none;"'; - } - // outputs an input field type TEXT - echo ''; - } - - /** - * outputs a input type=checkbox - * @param string $p_str_SettingsID [id of the settings field] - * @param string $p_str_ClassName [optional css class name] - * @since 1.0-beta - */ - public function AddCheckbox($p_str_SettingsID, $p_str_ClassName = "") { - require_once(dirname(__FILE__) . "/convert.php"); - // collect data for given settings field - $l_arr_Data = $this->LoadSetting($p_str_SettingsID); - - // if input shall have a css class, add the style tag for it - if (!empty($p_str_ClassName)) { - $p_str_ClassName = 'class="' . $p_str_ClassName . '"'; - } - - // lookup if the checkbox shall be pre-checked - $l_str_Checked = ""; - if (MCI_Footnotes_Convert::toBool($l_arr_Data["value"])) { - $l_str_Checked = 'checked="checked"'; - } - - // outputs an input field type CHECKBOX - echo sprintf('', $l_str_Checked); - } - - /** - * outputs a select box - * @param string $p_str_SettingsID [id of the settings field] - * @param array $p_arr_Options [array with options] - * @param string $p_str_ClassName [optional css class name] - * @since 1.0-beta - */ - public function AddSelect($p_str_SettingsID, $p_arr_Options, $p_str_ClassName = "") { - // collect data for given settings field - $l_arr_Data = $this->LoadSetting($p_str_SettingsID); - - // if input shall have a css class, add the style tag for it - if (!empty($p_str_ClassName)) { - $p_str_ClassName = 'class="' . $p_str_ClassName . '"'; - } - - // select starting tag - $l_str_Output = ''; - // outputs the SELECT field - echo $l_str_Output; - } - - /** - * outputs a textarea - * @param string $p_str_SettingsID [id of the settings field] - * @param int $p_int_Rows [amount of rows] - * @param string $p_str_ClassName [css class name] - * @since 1.3 - */ - public function AddTextarea($p_str_SettingsID, $p_int_Rows, $p_str_ClassName = "") { - // collect data for given settings field - $l_arr_Data = $this->LoadSetting($p_str_SettingsID); - - // if input shall have a css class, add the style tag for it - if (!empty($p_str_ClassName)) { - $p_str_ClassName = 'class="' . $p_str_ClassName . '"'; - } - // outputs an input field type TEXT - echo ''; - } - -}// class MCI_Footnotes_Admin - -endif; \ No newline at end of file diff --git a/classes/footnotes.php b/classes/footnotes.php deleted file mode 100644 index 16b6d70..0000000 --- a/classes/footnotes.php +++ /dev/null @@ -1,119 +0,0 @@ -a_obj_Task = new MCI_Footnotes_Task(); - $this->a_obj_Task->Register(); - } - - /** - * draw the dashboard setting - */ - public function generateLayout() { - // load plugin settings - require_once(dirname( __FILE__ ) . "/admin.php"); - $this->a_obj_Admin = new MCI_Footnotes_Admin(); - } - - /** - * activates the plugin - * @since 1.0 - */ - public static function activate() { - // unused - } - - /** - * deactivates the plugin - * @since 1.0 - */ - public static function deactivate() { - // unused - } - - /** - * uninstalls the plugin - * updated file path in version 1.0.6 - * @since 1.0 - */ - public static function uninstall() { - // uninstalling the plugin is only allowed for logged in users - if (!is_user_logged_in()) { - wp_die(__('You must be logged in to run this script.', FOOTNOTES_PLUGIN_NAME)); - } - - // current user needs the permission to (un)install plugins - if (!current_user_can('install_plugins')) { - wp_die(__('You do not have permission to run this script.', FOOTNOTES_PLUGIN_NAME)); - } - - // delete the settings container in the database - // @since 1.0.6 - delete_option(FOOTNOTES_SETTINGS_CONTAINER); - delete_option(FOOTNOTES_SETTINGS_CONTAINER_CUSTOM); - } - - /** - * load public styling and client function - * called in class constructor @ init - * @since 1.0 - */ - public function LoadScriptsAndStylesheets() { - // register public stylesheets - wp_register_style('MCI_Footnotes_public_style_General', plugins_url('../css/footnotes.css', __FILE__)); - wp_register_style('MCI_Footnotes_public_style_Tooltip', plugins_url('../css/tooltip.css', __FILE__)); - wp_register_style('MCI_Footnotes_public_style_ReferenceContainer', plugins_url('../css/reference_container.css', __FILE__)); - // add public stylesheets - wp_enqueue_style('MCI_Footnotes_public_style_General'); - wp_enqueue_style('MCI_Footnotes_public_style_Tooltip'); - wp_enqueue_style('MCI_Footnotes_public_style_ReferenceContainer'); - - // add the jQuery plugin (already registered by WP) - wp_enqueue_script('jquery'); - // add jquery tools to public page - wp_enqueue_script('footnotes_public_script', plugins_url('../js/jquery.tools.min.js', __FILE__), array()); - } - -} // class MCI_Footnotes - -endif; \ No newline at end of file diff --git a/classes/tab_custom.php b/classes/tab_custom.php deleted file mode 100644 index 952a189..0000000 --- a/classes/tab_custom.php +++ /dev/null @@ -1,127 +0,0 @@ -AddLabel(FOOTNOTES_INPUT_CUSTOM_STYLING_BEFORE, __("Before Footnotes index:", FOOTNOTES_PLUGIN_NAME)); - $this->AddTextbox(FOOTNOTES_INPUT_CUSTOM_STYLING_BEFORE, "footnote_plugin_50"); - $this->AddNewline(); - // setting for 'after footnotes' - $this->AddLabel(FOOTNOTES_INPUT_CUSTOM_STYLING_AFTER, __("After Footnotes index:", FOOTNOTES_PLUGIN_NAME)); - $this->AddTextbox(FOOTNOTES_INPUT_CUSTOM_STYLING_AFTER, "footnote_plugin_50"); - $this->AddNewline(); - } - - /** - * layout of the hyperlink symbol to jump to the footnotes index inside post - * @since 1.3.2 - * @return void - */ - public function HyperlinkSymbol() { - // load convert class - require_once(dirname(__FILE__) . "/convert.php"); - $this->AddLabel(FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL, __("Hyperlink symbol:", FOOTNOTES_PLUGIN_NAME)); - $this->AddSelect(FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL, MCI_Footnotes_Convert::getArrow(), "footnote_plugin_15"); - $this->AddNewline(); - - $this->AddLabel(FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL_USER, __("or enter a user defined symbol:", FOOTNOTES_PLUGIN_NAME)); - $this->AddTextbox(FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL_USER, "footnote_plugin_15"); - $this->AddText("   "); - $this->AddText("" . __("if set it overrides the hyperlink symbol above", FOOTNOTES_PLUGIN_NAME) . ""); - } - - /** - * customize css box for public page - * @since 1.3 - */ - public function CSS() { - $l_str_Separator = " ⇒ "; - // setting for 'reference label' - $this->AddLabel(FOOTNOTES_INPUT_CUSTOM_CSS, __("Add custom CSS:", FOOTNOTES_PLUGIN_NAME)); - $this->AddTextarea(FOOTNOTES_INPUT_CUSTOM_CSS, 12, "footnote_plugin_100"); - $this->AddNewline(); - - $this->AddText($this->Highlight(gettext("Available CSS classes to customize the footnotes and the reference container:")) . "
"); - - echo "
"; - $this->AddText($this->Highlight(".footnote_plugin_tooltip_text") . $l_str_Separator . gettext("inline footnotes") . "
"); - $this->AddText($this->Highlight(".footnote_tooltip") . $l_str_Separator . gettext("inline footnotes, mouse over highlight box") . "

"); - - $this->AddText($this->Highlight(".footnote_plugin_index") . $l_str_Separator . gettext("reference container footnotes index") . "
"); - $this->AddText($this->Highlight(".footnote_plugin_link") . $l_str_Separator . gettext("reference container footnotes linked arrow") . "
"); - $this->AddText($this->Highlight(".footnote_plugin_text") . $l_str_Separator . gettext("reference container footnotes text")); - echo "
"; - } -} // class MCI_Footnotes_Tab_Custom - -endif; \ No newline at end of file diff --git a/classes/tab_diagnostics.php b/classes/tab_diagnostics.php deleted file mode 100644 index 529c16b..0000000 --- a/classes/tab_diagnostics.php +++ /dev/null @@ -1,119 +0,0 @@ -'; - echo ''; - - // website - echo ''; - echo '' . $this->Highlight(__('Server name', FOOTNOTES_PLUGIN_NAME)) . ''; - echo '' . $_SERVER["SERVER_NAME"] . ''; - echo ''; - - // PHP version - echo ''; - echo '' . $this->Highlight(__('PHP version', FOOTNOTES_PLUGIN_NAME)) . ''; - echo '' . phpversion() . ''; - echo ''; - - // max. execution time - echo ''; - echo '' . $this->Highlight(__('Max execution time', FOOTNOTES_PLUGIN_NAME)) . ''; - echo '' . ini_get('max_execution_time') . ' ' . __('seconds', FOOTNOTES_PLUGIN_NAME) . ''; - echo ''; - - // memory limit - echo ''; - echo '' . $this->Highlight(__('Memory limit', FOOTNOTES_PLUGIN_NAME)) . ''; - echo '' . ini_get('memory_limit') . ''; - echo ''; - - // PHP extensions - echo ''; - echo '' . $this->Highlight(__('PHP extensions', FOOTNOTES_PLUGIN_NAME)) . ''; - echo ''; - foreach (get_loaded_extensions() as $l_int_Index => $l_str_Extension) { - if ($l_int_Index > 0) { - echo ' | '; - } - echo $l_str_Extension . ' ' . phpversion($l_str_Extension); - } - echo ''; - echo ''; - - // WordPress version - echo ''; - echo '' . $this->Highlight(__('WordPress version', FOOTNOTES_PLUGIN_NAME)) . ''; - echo '' . $wp_version . ''; - echo ''; - - // WordPress Plugins installed - foreach (get_plugins() as $l_arr_Plugin) { - echo ''; - echo '' . $this->Highlight($l_arr_Plugin["Name"]) . ''; - echo '' . $l_arr_Plugin["Version"] . ' [' . $l_arr_Plugin["PluginURI"] . ']' . ''; - echo ''; - } - - echo ''; - echo ''; - } -} // class MCI_Footnotes_Tab_Diagnostics - -endif; \ No newline at end of file diff --git a/classes/tab_general.php b/classes/tab_general.php deleted file mode 100644 index 3850185..0000000 --- a/classes/tab_general.php +++ /dev/null @@ -1,190 +0,0 @@ -AddLabel(FOOTNOTES_INPUT_REFERENCES_LABEL, __("References label:", FOOTNOTES_PLUGIN_NAME)); - $this->AddTextbox(FOOTNOTES_INPUT_REFERENCES_LABEL, "footnote_plugin_50"); - $this->AddNewline(); - // setting for 'collapse reference container by default' - $this->AddLabel(FOOTNOTES_INPUT_COLLAPSE_REFERENCES, __("Collapse references by default:", FOOTNOTES_PLUGIN_NAME)); - $this->AddCheckbox(FOOTNOTES_INPUT_COLLAPSE_REFERENCES); - $this->AddNewline(); - // setting for 'placement of the reference container' - // @since 1.0.7 - $l_arr_Options = array( - "footer" => __("in the footer", FOOTNOTES_PLUGIN_NAME), - "post_end" => __("at the end of the post", FOOTNOTES_PLUGIN_NAME), - "widget" => __("in the widget area", FOOTNOTES_PLUGIN_NAME) - ); - $this->AddLabel(FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE, __("Where shall the reference container appear:", FOOTNOTES_PLUGIN_NAME)); - $this->AddSelect(FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE, $l_arr_Options, "footnote_plugin_50"); - } - - /** - * output the setting fields for the footnotes styling - * @since 1.3 - */ - public function Styling() { - // setting for 'combine identical footnotes' - $l_arr_Options = array( - "yes" => __("Yes", FOOTNOTES_PLUGIN_NAME), - "no" => __("No", FOOTNOTES_PLUGIN_NAME) - ); - $this->AddLabel(FOOTNOTES_INPUT_COMBINE_IDENTICAL, __("Combine identical footnotes:", FOOTNOTES_PLUGIN_NAME)); - $this->AddSelect(FOOTNOTES_INPUT_COMBINE_IDENTICAL, $l_arr_Options, "footnote_plugin_50"); - $this->AddNewline(); - // setting for 'footnote tag starts with' - $l_arr_Options = array( - "((" => "((", - "" => htmlspecialchars(""), - "[ref]" => "[ref]", - "userdefined" => __('user defined', FOOTNOTES_PLUGIN_NAME) - ); - $this->AddLabel(FOOTNOTES_INPUT_PLACEHOLDER_START, __("Footnote tag starts with:", FOOTNOTES_PLUGIN_NAME)); - $this->AddSelect(FOOTNOTES_INPUT_PLACEHOLDER_START, $l_arr_Options, "footnote_plugin_15"); - // setting for 'footnote tag ends with' - $l_arr_Options = array( - "))" => "))", - "" => htmlspecialchars(""), - "[/ref]" => "[/ref]", - "userdefined" => __('user defined', FOOTNOTES_PLUGIN_NAME) - ); - $this->AddLabel(FOOTNOTES_INPUT_PLACEHOLDER_END, __("and ends with:", FOOTNOTES_PLUGIN_NAME) . '   ', 'text-align: right;'); - $this->AddSelect(FOOTNOTES_INPUT_PLACEHOLDER_END, $l_arr_Options, "footnote_plugin_15"); - $this->AddNewline(); - // user defined setting for 'footnote start and end tag' - $this->AddLabel(FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED, ""); - $this->AddTextbox(FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED, "footnote_plugin_15", 14, false, true); - $this->AddLabel(FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED, ""); - $this->AddTextbox(FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED, "footnote_plugin_15", 14, false, true); - $this->AddNewline(); - // setting for 'footnotes counter style' - $l_str_Space = "     "; - $l_arr_Options = array( - "arabic_plain" => __("Arabic Numbers - Plain", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "1, 2, 3, 4, 5, ...", - "arabic_leading" => __("Arabic Numbers - Leading 0", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "01, 02, 03, 04, 05, ...", - "latin_low" => __("Latin Character - lower case", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "a, b, c, d, e, ...", - "latin_high" => __("Latin Character - upper case", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "A, B, C, D, E, ...", - "romanic" => __("Roman Numerals", FOOTNOTES_PLUGIN_NAME) . $l_str_Space . "I, II, III, IV, V, ..." - ); - $this->AddLabel(FOOTNOTES_INPUT_COUNTER_STYLE, __('Counter style:', FOOTNOTES_PLUGIN_NAME)); - $this->AddSelect(FOOTNOTES_INPUT_COUNTER_STYLE, $l_arr_Options, "footnote_plugin_50"); - } - - /** - * output the setting fields to love and share the footnotes plugin - * @since 1.3 - */ - public function Love() { - // setting for 'love and share this plugin in my footer' - $l_arr_Options = array( - "text-1" => sprintf(__('I %s %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_LOVE_SYMBOL, FOOTNOTES_PLUGIN_PUBLIC_NAME), - "text-2" => sprintf(__('this site uses the awesome %s Plugin', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME), - "text-3" => sprintf(__('extra smooth %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME), - "random" => __('random text', FOOTNOTES_PLUGIN_NAME), - "no" => sprintf(__("Don't display a %s %s text in my footer.", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME, FOOTNOTES_LOVE_SYMBOL) - ); - $this->AddLabel(FOOTNOTES_INPUT_LOVE, sprintf(__("Tell the world you're using %s:", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME)); - $this->AddSelect(FOOTNOTES_INPUT_LOVE, $l_arr_Options, "footnote_plugin_50"); - $this->AddNewline(); - // no 'love me' on specific pages - $this->AddText(sprintf(__("Don't tell the world you're using %s on specific pages by adding the following short code:", FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME)); - $this->AddText("      "); - $this->AddText(FOOTNOTES_NO_SLUGME_PLUG); - } - - /** - * output settings fields with no specific topic - * @since 1.3 - */ - public function Other() { - // setting for 'search footnotes tag in excerpt' - $l_arr_Options = array( - "yes" => __("Yes", FOOTNOTES_PLUGIN_NAME), - "no" => __("No", FOOTNOTES_PLUGIN_NAME) - ); - $this->AddLabel(FOOTNOTES_INPUT_SEARCH_IN_EXCERPT, __('Allow footnotes on Summarized Posts:', FOOTNOTES_PLUGIN_NAME)); - $this->AddSelect(FOOTNOTES_INPUT_SEARCH_IN_EXCERPT, $l_arr_Options, "footnote_plugin_50"); - } -} // class MCI_Footnotes_Tab_General - -endif; \ No newline at end of file diff --git a/classes/tab_howto.php b/classes/tab_howto.php deleted file mode 100644 index c8d05f6..0000000 --- a/classes/tab_howto.php +++ /dev/null @@ -1,119 +0,0 @@ -LoadSetting(FOOTNOTES_INPUT_PLACEHOLDER_START); - $l_arr_Footnote_EndingTag = $this->LoadSetting(FOOTNOTES_INPUT_PLACEHOLDER_END); - - if ($l_arr_Footnote_StartingTag["value"] == "userdefined" || $l_arr_Footnote_EndingTag["value"] == "userdefined") { - // load user defined starting and end tag - $l_arr_Footnote_StartingTag = $this->LoadSetting(FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED); - $l_arr_Footnote_EndingTag = $this->LoadSetting(FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED); - } - $l_str_Example = "Hello" . $l_arr_Footnote_StartingTag["value"] . __("example string", FOOTNOTES_PLUGIN_NAME) . $l_arr_Footnote_EndingTag["value"] . " World!"; - ?> -
-
-

- - - - -

-

- - - - -

-
-

- - -      - a_obj_Task->exec($l_str_Example, true); ?> -

-
-

- ', ''); ?> -

-
-
- '; - } -} // class MCI_Footnotes_Tab_HowTo - -endif; \ No newline at end of file diff --git a/classes/task.php b/classes/task.php deleted file mode 100644 index be54f79..0000000 --- a/classes/task.php +++ /dev/null @@ -1,394 +0,0 @@ -a_arr_Settings = MCI_Footnotes_getOptions(false); - } - - /** - * add WordPress hooks - * @since 1.3 - */ - public function Register() { - // adds the custom css to the header - add_action('wp_head', array($this, "Header")); - // stops listening to the output and replaces the footnotes - add_action('get_footer', array($this, "Footer")); - // adds the love and share me slug to the footer - add_action('wp_footer', array($this, "Love")); - - // moves these contents through the replacement function - add_filter('the_content', array($this, "Content")); - add_filter('the_excerpt', array($this, "Excerpt")); - add_filter('widget_title', array($this, "WidgetTitle")); - add_filter('widget_text', array($this, "WidgetText")); - } - - /** - * outputs the custom css to the header - * @since 1.3 - */ - public function Header() { - ?> - - exec($p_str_Content, $this->a_arr_Settings[FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE] == "post_end" ? true : false); - } - - /** - * replaces footnotes tags in the post excerpt - * @since 1.3 - * @param string $p_str_Content - * @return string - */ - public function Excerpt($p_str_Content) { - require_once(dirname( __FILE__ ) . "/convert.php"); - // search in the excerpt only if activated - if (MCI_Footnotes_Convert::toBool($this->a_arr_Settings[FOOTNOTES_INPUT_SEARCH_IN_EXCERPT])) { - return $this->exec($p_str_Content, false); - } - // returns content - return $p_str_Content; - } - - /** - * replaces footnotes tags in the widget title - * @since 1.3 - * @param string $p_str_Content - * @return string - */ - public function WidgetTitle($p_str_Content) { - // returns content - return $p_str_Content; - } - - /** - * replaces footnotes tags in the widget text - * @since 1.3 - * @param string $p_str_Content - * @return string - */ - public function WidgetText($p_str_Content) { - // returns content - return $this->exec($p_str_Content, $this->a_arr_Settings[FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE] == "post_end" ? true : false); - } - - /** - * outputs the reference container to the footer - * @since 1.3 - */ - public function Footer() { - if ($this->a_arr_Settings[FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE] == "footer") { - echo $this->ReferenceContainer(); - } - } - - /** - * output the love me slug in the footer - * @since 1.3 - */ - public function Love() { - // get setting for love and share this plugin and convert it to boolean - $l_str_LoveMeText = $this->a_arr_Settings[FOOTNOTES_INPUT_LOVE]; - // check if the admin allows to add a link to the footer - if (empty($l_str_LoveMeText) || strtolower($l_str_LoveMeText) == "no" || !self::$a_bool_AllowLoveMe) { - return; - } - // get random love me text - if (strtolower($l_str_LoveMeText) == "random") { - $l_str_LoveMeText = "text-" . rand(1,3); - } - switch ($l_str_LoveMeText) { - case "text-1": - $l_str_LoveMeText = sprintf(__('I %s %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_LOVE_SYMBOL, FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED); - break; - case "text-2": - $l_str_LoveMeText = sprintf(__('this site uses the awesome %s Plugin', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED); - break; - case "text-3": - default: - $l_str_LoveMeText = sprintf(__('extra smooth %s', FOOTNOTES_PLUGIN_NAME), FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED); - break; - } - echo '
' . $l_str_LoveMeText . '
'; - } - - - /** - * replaces all footnotes in the given content - * loading settings if not happened yet since 1.0-gamma - * @since 1.0 - * @param string $p_str_Content - * @param bool $p_bool_OutputReferences [default: true] - * @return string - */ - public function exec($p_str_Content, $p_bool_OutputReferences = true) { - // replace all footnotes in the content - $p_str_Content = $this->Lookup($p_str_Content, true); - $p_str_Content = $this->Lookup($p_str_Content, false); - - // add the reference list if set - if ($p_bool_OutputReferences) { - $p_str_Content = $p_str_Content . $this->ReferenceContainer(); - } - // checks if the user doesn't want to have a 'love me' on current page - // @since 1.1.1 - if (strpos($p_str_Content, FOOTNOTES_NO_SLUGME_PLUG) !== false) { - self::$a_bool_AllowLoveMe = false; - $p_str_Content = str_replace(FOOTNOTES_NO_SLUGME_PLUG, "", $p_str_Content); - } - // return the replaced content - return $p_str_Content; - } - - /** - * replace all footnotes in the given string and adds them to an array - * using a personal starting and ending tag for the footnotes since 1.0-gamma - * @since 1.0 - * @param string $p_str_Content - * @param bool $p_bool_ConvertHtmlChars - * @return string - */ - public function Lookup($p_str_Content, $p_bool_ConvertHtmlChars = true) { - require_once(dirname( __FILE__ ) . "/convert.php"); - // contains the index for the next footnote on this page - $l_int_FootnoteIndex = count(self::$a_arr_Footnotes) + 1; - // contains the starting position for the lookup of a footnote - $l_int_PosStart = 0; - // contains the footnote template - $l_str_FootnoteTemplate = file_get_contents(FOOTNOTES_TEMPLATES_DIR . "footnote.html"); - // get footnote starting tag - $l_str_StartingTag = $this->a_arr_Settings[FOOTNOTES_INPUT_PLACEHOLDER_START]; - // get footnote ending tag - $l_str_EndingTag = $this->a_arr_Settings[FOOTNOTES_INPUT_PLACEHOLDER_END]; - // get footnote counter style - $l_str_CounterStyle = $this->a_arr_Settings[FOOTNOTES_INPUT_COUNTER_STYLE]; - // get footnote layout before index - $l_str_BeforeIndex = $this->a_arr_Settings[FOOTNOTES_INPUT_CUSTOM_STYLING_BEFORE]; - // get footnote layout after index - $l_str_AfterIndex = $this->a_arr_Settings[FOOTNOTES_INPUT_CUSTOM_STYLING_AFTER]; - - if ($l_str_StartingTag == "userdefined" || $l_str_EndingTag == "userdefined") { - // get user defined footnote starting tag - $l_str_StartingTag = $this->a_arr_Settings[FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED]; - // get user defined footnote ending tag - $l_str_EndingTag = $this->a_arr_Settings[FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED]; - } - - // decode html special chars - if ($p_bool_ConvertHtmlChars) { - $l_str_StartingTag = htmlspecialchars($l_str_StartingTag); - $l_str_EndingTag = htmlspecialchars($l_str_EndingTag); - } - // if footnotes short code is empty, return the content without changes - if (empty($l_str_StartingTag) || empty($l_str_EndingTag)) { - return $p_str_Content; - } - - // check for a footnote placeholder in the current page - do { - // get first occurrence of a footnote starting tag - $l_int_PosStart = strpos($p_str_Content, $l_str_StartingTag, $l_int_PosStart); - // tag not found - if ($l_int_PosStart === false) { - break; - } - // get first occurrence of a footnote ending tag after the starting tag - $l_int_PosEnd = strpos($p_str_Content, $l_str_EndingTag, $l_int_PosStart); - // tag not found - if ($l_int_PosEnd === false) { - break; - } - // get length of footnote text - $l_int_Length = $l_int_PosEnd - $l_int_PosStart; - // get text inside footnote - $l_str_FootnoteText = substr($p_str_Content, $l_int_PosStart + strlen($l_str_StartingTag), $l_int_Length - strlen($l_str_StartingTag)); - // set replacing string for the footnote - $l_str_ReplaceText = str_replace("[[FOOTNOTE INDEX]]", MCI_Footnotes_Convert::Index($l_int_FootnoteIndex, $l_str_CounterStyle), $l_str_FootnoteTemplate); - $l_str_ReplaceText = str_replace("[[FOOTNOTE TEXT]]", $l_str_FootnoteText, $l_str_ReplaceText); - $l_str_ReplaceText = str_replace("[[FOOTNOTE BEFORE]]", $l_str_BeforeIndex, $l_str_ReplaceText); - $l_str_ReplaceText = str_replace("[[FOOTNOTE AFTER]]", $l_str_AfterIndex, $l_str_ReplaceText); - $l_str_ReplaceText = preg_replace('@[\s]{2,}@',' ',$l_str_ReplaceText); - // replace footnote in content - $p_str_Content = substr_replace($p_str_Content, $l_str_ReplaceText, $l_int_PosStart, $l_int_Length + strlen($l_str_EndingTag)); - // add footnote only if not empty - if (!empty($l_str_FootnoteText)) { - // set footnote to the output box at the end - self::$a_arr_Footnotes[] = $l_str_FootnoteText; - // increase footnote index - $l_int_FootnoteIndex++; - } - // add offset to the new starting position - $l_int_PosStart += $l_int_Length + strlen($l_str_EndingTag); - } while (true); - - // return content - return $p_str_Content; - } - - /** - * looks through all footnotes that has been replaced in the current content and - * adds a reference to the footnote at the end of the content - * function to collapse the reference container since 1.0-beta - * @since 1.0 - * @return string - */ - public function ReferenceContainer() { - // no footnotes has been replaced on this page - if (empty(self::$a_arr_Footnotes)) { - return ""; - } - require_once(dirname( __FILE__ ) . "/convert.php"); - - // get setting for combine identical footnotes and convert it to boolean - $l_bool_CombineIdentical = MCI_Footnotes_Convert::toBool($this->a_arr_Settings[FOOTNOTES_INPUT_COMBINE_IDENTICAL]); - // get setting for preferences label - $l_str_ReferencesLabel = $this->a_arr_Settings[FOOTNOTES_INPUT_REFERENCES_LABEL]; - // get setting for collapse reference footnotes and convert it to boolean - $l_bool_CollapseReference = MCI_Footnotes_Convert::toBool($this->a_arr_Settings[FOOTNOTES_INPUT_COLLAPSE_REFERENCES]); - // get footnote counter style - $l_str_CounterStyle = $this->a_arr_Settings[FOOTNOTES_INPUT_COUNTER_STYLE]; - // get hyperlink symbol index - $l_int_HyperlinkSymbolIndex = $this->a_arr_Settings[FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL]; - // get html arrow - $l_str_HyperlinkSymbol = MCI_Footnotes_Convert::getArrow($l_int_HyperlinkSymbolIndex); - // set html arrow to the first one if invalid index defined - if (is_array($l_str_HyperlinkSymbol)) { - $l_str_HyperlinkSymbol = MCI_Footnotes_Convert::getArrow(0); - } - // get user defined hyperlink symbol - $l_int_HyperlinkSymbol_UserDefined = $this->a_arr_Settings[FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL_USER]; - if (!empty($l_int_HyperlinkSymbol_UserDefined)) { - // override hyperlink symbol with user defined symbol - $l_str_HyperlinkSymbol = $l_int_HyperlinkSymbol_UserDefined; - } - - // add expand/collapse buttons to the reference label if collapsed by default - // @since 1.2.2 - $l_str_CollapseButtons = ""; - if ($l_bool_CollapseReference) { - $l_str_CollapseButtons = '   [ + ]'; - } - - // output string, prepare it with the reference label as headline - $l_str_Output = '

' . $l_str_ReferencesLabel . '' .$l_str_CollapseButtons . '

'; - // add a box around the footnotes - $l_str_Output .= '
0) { - jQuery(p_str_ID).focus(); - } - } - function footnote_expand_collapse_reference_container() { - var l_obj_ReferenceContainer = jQuery("#' . FOOTNOTES_REFERENCES_CONTAINER_ID . '"); - if (l_obj_ReferenceContainer.is(":hidden")) { - l_obj_ReferenceContainer.show(); - jQuery("#footnote_reference_container_collapse_button").text("-"); - } else { - l_obj_ReferenceContainer.hide(); - jQuery("#footnote_reference_container_collapse_button").text("+"); - } - } - - '; - - // free all found footnotes if reference container will be displayed - self::$a_arr_Footnotes = array(); - // return the output string - return $l_str_Output; - } - -} // class MCI_Footnotes_Task - -endif; \ No newline at end of file diff --git a/classes/widget.php b/classes/widget.php deleted file mode 100644 index bb0a3c9..0000000 --- a/classes/widget.php +++ /dev/null @@ -1,70 +0,0 @@ - 'Class_FootnotesWidget', - 'description' => __('The widget defines the position of the reference container if set to "widget area".', FOOTNOTES_PLUGIN_NAME) - ); - // set widget layout information - $l_arr_WidgetLayout = array( - 'width' => 300, - 'height' => 350, - 'id_base' => 'footnotes_widget' - ); - // add widget to the list - $this->WP_Widget('footnotes_widget', FOOTNOTES_PLUGIN_NAME, $l_arr_WidgetMeta, $l_arr_WidgetLayout); - } - - /** - * widget form creation - * @param $instance - * @return void - */ - public function form($instance) { - echo __('The widget defines the position of the reference container if set to "widget area".', FOOTNOTES_PLUGIN_NAME); - } - - /** - * widget update - * @param $new_instance - * @param $old_instance - * @return mixed - */ - public function update($new_instance, $old_instance) { - return $new_instance; - } - - /** - * widget display - * @param $args - * @param $instance - */ - public function widget($args, $instance) { - global $g_obj_MCI_Footnotes; - // reference container positioning is set to "widget area" - if ($g_obj_MCI_Footnotes->a_obj_Task->a_arr_Settings[FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE] == "widget") { - echo $g_obj_MCI_Footnotes->a_obj_Task->ReferenceContainer(); - } - } -} // class MCI_Footnotes_Widget - -endif; \ No newline at end of file diff --git a/css/reference_container.css b/css/reference_container.css index 876bcc5..4323cc6 100644 --- a/css/reference_container.css +++ b/css/reference_container.css @@ -39,46 +39,28 @@ .footnote_container_prepare > p > span:last-child { } -/* container for the footnote in the bottom */ -.footnote_plugin_container { - display: block !important; - width: 100% !important; - padding-bottom: 14px !important; -} - -/* footnote (bottom) index */ -.footnote_plugin_index { - /*float: left !important;*/ - min-width: 40px !important; - white-space: nowrap !important; - text-align: right !important; - display: inline-block; -} - -/* footnote (bottom) text */ -.footnote_plugin_text { - /*float: left !important;*/ - padding-left: 16px !important; - display: inline; -} - -/* footnote (bottom) link to the footnote implementation */ -.footnote_plugin_link { - outline: none !important; - text-decoration: none !important; - cursor: pointer !important; -} - -.footnote_plugin_link:hover { - /*color: #4777ff !important;*/ - text-decoration: none !important; -} - -/* footnote (bottom) styling end tag */ -.footnote_plugin_end { - /*clear: left !important;*/ -} - .footnote_hide_box { display: none; +} + +.footnote-reference-container { + width: 100%; + border: none; +} + +.footnote-reference-container > tbody > tr > td:first-child { + white-space: nowrap; + padding-right: 5px; + text-align: left; +} + +.footnote-reference-container > tbody > tr > td:nth-child(2) { + white-space: nowrap; + padding-right: 5px; + text-align: left; +} + +.footnote-reference-container > tbody > tr > td:last-child { + width: 99%; + text-align: left; } \ No newline at end of file diff --git a/css/settings.css b/css/settings.css index ead8280..7e1b0f9 100755 --- a/css/settings.css +++ b/css/settings.css @@ -8,71 +8,41 @@ */ input[type=text], input[type=password], textarea, select { - padding-left: 8px !important; - padding-right: 8px !important; + padding-left: 8px !important; + padding-right: 8px !important; + width: 80% !important; +} + +textarea { + height: 250px; } label { - width: 20% !important; - display: inline-block; + display: inline-block; } -/* - * layout for the meta box container - * @since 1.0.7 -*/ .postbox > h3 { - height: 32px !important; - line-height: 32px !important; + height: 32px !important; + line-height: 32px !important; } .postbox > h3 > span { - padding-left: 10px; + padding-left: 10px; } -/* overwrite link layout on the settings page */ -a.footnote_plugin { - text-decoration: underline !important; - cursor: pointer !important; - color: #202020 !important; +.postbox > .inside > table { + border: none !important; } -/* setting with 15% width */ -.footnote_plugin_15 { - width: 15% !important; +.postbox > .inside >table > tbody > tr > td:first-child { + width: 15% !important; + font-weight: bold !important; } -/* setting with 25% width */ -.footnote_plugin_25 { - width: 25% !important; -} - -/* setting with half width */ -.footnote_plugin_50 { - width: 50% !important; -} - -/* setting with 75% width */ -.footnote_plugin_75 { - width: 75% !important; -} - -/* setting with full width */ -.footnote_plugin_100 { - width: 100% !important; -} - -/* container for the box holding the placeholder tags at the end */ .footnote_placeholder_box_container { text-align: center !important; - /*width: auto; - display: inline-block; - padding-left: 20px; - padding-right: 20px; - margin-left: -210px;*/ } -/* highlight the placeholders */ span.footnote_highlight_placeholder { font-weight: bold !important; padding-left: 8px !important; @@ -87,4 +57,5 @@ span.footnote_highlight_placeholder { width: 50% !important; display: block !important; margin: 20px auto !important; + text-align: center !important; } \ No newline at end of file diff --git a/includes.php b/includes.php new file mode 100644 index 0000000..259fcbf --- /dev/null +++ b/includes.php @@ -0,0 +1,37 @@ +footnotes'); -// PLUGIN PUBLIC NAME WITH STYLING AND LINK -// @since 1.2.2 -define("FOOTNOTES_PLUGIN_PUBLIC_NAME_LINKED", '' . FOOTNOTES_PLUGIN_PUBLIC_NAME . ''); -// PLUGIN LOVE SYMBOL WITH STYLING -// @since 1.2.2 -define("FOOTNOTES_LOVE_SYMBOL", ''); - - -// PLUGIN DIRECTORIES -define("FOOTNOTES_PLUGIN_DIR_NAME", "footnotes"); -define("FOOTNOTES_LANGUAGE_DIR", dirname(__FILE__) . "/../languages/"); -define("FOOTNOTES_TEMPLATES_DIR", dirname(__FILE__) . "/../templates/"); - - -// SETTINGS CONTAINER -define("FOOTNOTES_SETTINGS_CONTAINER", "footnotes_storage"); // database container where all footnote settings are stored -define("FOOTNOTES_SETTINGS_CONTAINER_CUSTOM", "footnotes_storage_custom"); // database container where all 'custom' settings are stored -// PLUGIN SETTINGS PAGE -define("FOOTNOTES_SETTINGS_PAGE_ID", "footnotes"); // plugins setting page internal id -// PLUGIN SETTINGS PAGE TABS -define("FOOTNOTES_SETTINGS_TAB_GENERAL", "footnotes_general_settings"); // internal label for the plugins general settings tab -define("FOOTNOTES_SETTINGS_TAB_CUSTOM", "footnotes_custom_settings"); // internal label for the plugins custom settings tab -define("FOOTNOTES_SETTINGS_TAB_HOWTO", "footnotes_howto_settings"); // internal label for the plugins how to tab -define("FOOTNOTES_SETTINGS_TAB_DIAGNOSTICS", "footnotes_diagnostics_settings"); // internal label for the plugins diagnostics tab - -// PLUGIN SETTINGS INPUT FIELDS -define("FOOTNOTES_INPUT_COMBINE_IDENTICAL", "footnote_inputfield_combine_identical"); // id of input field for the combine identical setting -define("FOOTNOTES_INPUT_REFERENCES_LABEL", "footnote_inputfield_references_label"); // id of input field for the references label setting -define("FOOTNOTES_INPUT_COLLAPSE_REFERENCES", "footnote_inputfield_collapse_references"); // id of input field for the "collapse references" setting -define("FOOTNOTES_INPUT_PLACEHOLDER_START", "footnote_inputfield_placeholder_start"); // id of input field for the "placeholder starting tag" setting -define("FOOTNOTES_INPUT_PLACEHOLDER_END", "footnote_inputfield_placeholder_end"); // id of input field for the "placeholder ending tag" setting -define("FOOTNOTES_INPUT_SEARCH_IN_EXCERPT", "footnote_inputfield_search_in_excerpt"); // id of input field for the "allow footnotes in the excerpt" setting -define("FOOTNOTES_INPUT_LOVE", "footnote_inputfield_love"); // id of input field for "love and share this plugin" setting -define("FOOTNOTES_INPUT_COUNTER_STYLE", "footnote_inputfield_counter_style"); // id of input field for "counter style of footnote index" setting -define("FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE", "footnote_inputfield_reference_container_place"); // id of input field "placement of reference container" setting -define("FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED", "footnote_inputfield_placeholder_start_user_defined"); // id of input field for 'user defined placeholder start tag -define("FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED", "footnote_inputfield_placeholder_end_user_defined"); // id of input field for 'user defined placeholder end tag -define("FOOTNOTES_INPUT_CUSTOM_CSS", "footnote_inputfield_custom_css"); // id of input field for 'custom css' setting -define("FOOTNOTES_INPUT_CUSTOM_STYLING_BEFORE", "footnote_inputfield_custom_styling_before"); // id of input field for 'footnotes styling before' setting -define("FOOTNOTES_INPUT_CUSTOM_STYLING_AFTER", "footnote_inputfield_custom_styling_after"); // id of input field for 'footnotes styling after' setting -define("FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL", "footnote_inputfield_custom_hyperlink_symbol"); // id of input field for 'footnotes hyperlink symbol' setting -define("FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL_USER", "footnote_inputfield_custom_hyperlink_symbol_user"); // id of input field for 'footnotes hyperlink symbol' user-defined setting - -// PLUGIN REFERENCES CONTAINER ID -define("FOOTNOTES_REFERENCES_CONTAINER_ID", "footnote_references_container"); // id for the div surrounding the footnotes -define("FOOTNOTES_REFERENCE_CONTAINER_POSITION", "[[footnotes reference container position]]"); - - -// PLUGIN PLACEHOLDER TO NOT DISPLAY THE 'LOVE ME' SLUG -// @since 1.1.1 -define("FOOTNOTES_NO_SLUGME_PLUG", "[[no footnotes: love]]"); \ No newline at end of file diff --git a/includes/language.php b/includes/language.php deleted file mode 100644 index ff7d579..0000000 --- a/includes/language.php +++ /dev/null @@ -1,55 +0,0 @@ -' . __('Settings', FOOTNOTES_PLUGIN_NAME) . ''; - // add link to the footnotes plugin support page on wordpress.org - $l_str_Support = '' . __('Support', FOOTNOTES_PLUGIN_NAME) . ''; - // add link to Donate - $l_str_Donate = '' . __('Donate', FOOTNOTES_PLUGIN_NAME) . ''; - - // add defined links to the plugin main page - $p_arr_Links[] = $l_str_Support; - $p_arr_Links[] = $l_str_Settings; - $p_arr_Links[] = $l_str_Donate; - - // return new links - return $p_arr_Links; -} - -/** - * reads a option field, filters the values and returns the filtered option array - * fallback to default value since 1.0-gamma - * @since 1.0 - * @param bool $p_bool_ConvertHtmlChars - * @return array - */ -function MCI_Footnotes_getOptions($p_bool_ConvertHtmlChars = true) { - // default settings for the 'general' settings container - $l_arr_Default_General = array( - FOOTNOTES_INPUT_COMBINE_IDENTICAL => 'yes', - FOOTNOTES_INPUT_REFERENCES_LABEL => 'References', - FOOTNOTES_INPUT_COLLAPSE_REFERENCES => '', - FOOTNOTES_INPUT_PLACEHOLDER_START => '((', - FOOTNOTES_INPUT_PLACEHOLDER_END => '))', - FOOTNOTES_INPUT_SEARCH_IN_EXCERPT => 'yes', - FOOTNOTES_INPUT_LOVE => 'no', - FOOTNOTES_INPUT_COUNTER_STYLE => 'arabic_plain', - FOOTNOTES_INPUT_REFERENCE_CONTAINER_PLACE => 'post_end', - FOOTNOTES_INPUT_PLACEHOLDER_START_USERDEFINED => '', - FOOTNOTES_INPUT_PLACEHOLDER_END_USERDEFINED => '' - ); - // default settings for the 'custom' settings container - $l_arr_Default_Custom = array( - FOOTNOTES_INPUT_CUSTOM_CSS => '', - FOOTNOTES_INPUT_CUSTOM_STYLING_BEFORE => '', - FOOTNOTES_INPUT_CUSTOM_STYLING_AFTER => ')', - FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL => '↑', - FOOTNOTES_INPUT_CUSTOM_HYPERLINK_SYMBOL_USER => '' - ); - - $l_arr_General = MCI_Footnotes_ValidateOptions(get_option(FOOTNOTES_SETTINGS_CONTAINER), $l_arr_Default_General, $p_bool_ConvertHtmlChars); - $l_arr_Custom = MCI_Footnotes_ValidateOptions(get_option(FOOTNOTES_SETTINGS_CONTAINER_CUSTOM), $l_arr_Default_Custom, $p_bool_ConvertHtmlChars); - - return array_merge($l_arr_General, $l_arr_Custom); -} - -/** - * validate each option, fallback is the default value - * @since 1.3 - * @param array $p_arr_Options - * @param array $p_arr_Default - * @param bool $p_bool_ConvertHtmlChars - * @return array - */ -function MCI_Footnotes_ValidateOptions($p_arr_Options, $p_arr_Default, $p_bool_ConvertHtmlChars) { - // if no settings set yet return default values - if (empty($p_arr_Options)) { - return $p_arr_Default; - } - // loop through all keys in the array and filters them - foreach ($p_arr_Options as $l_str_Key => $l_str_Value) { - // removes special chars from the settings value - $l_str_Value = stripcslashes($l_str_Value); - // if set, convert html special chars - if ($p_bool_ConvertHtmlChars) { - $l_str_Value = htmlspecialchars($l_str_Value); - } - // check if settings value is not empty, otherwise load the default value, or empty string if no default is defined - if (!empty($l_str_Value)) { - $p_arr_Options[$l_str_Key] = $l_str_Value; - // check if default value is defined - //} else if (array_key_exists($l_str_Key, $p_arr_Default)) { - // $p_arr_Options[$l_str_Key] = $p_arr_Default[$l_str_Key]; - } else { - $p_arr_Options[$l_str_Key] = ""; - } - } - - // check if each key from the default values exist in return array - foreach($p_arr_Default as $l_str_Key => $l_str_Value) { - // if key not exists, add it with its default value - if (!array_key_exists($l_str_Key, $p_arr_Options)) { - $p_arr_Options[$l_str_Key] = $l_str_Value; - } - } - // returns the filtered array - return $p_arr_Options; -} \ No newline at end of file diff --git a/includes/wysiwyg-editor.php b/includes/wysiwyg-editor.php deleted file mode 100644 index b5555b1..0000000 --- a/includes/wysiwyg-editor.php +++ /dev/null @@ -1,122 +0,0 @@ - - - $l_str_StartingTag, "end" => $l_str_EndingTag)); - exit; -} \ No newline at end of file diff --git a/index.php b/index.php index a397780..705ff52 100755 --- a/index.php +++ b/index.php @@ -4,7 +4,7 @@ Plugin URI: http://wordpress.org/plugins/footnotes/ Description: time to bring footnotes to your website! footnotes are known from offline publishing and everybody takes them for granted when reading a magazine. Author: ManFisher Medien ManuFaktur - Version: 1.4.0 + Version: 1.5.0 Author URI: http://manfisher.net/plugins/footnotes/ Text Domain: footnotes Domain Path: /languages @@ -25,48 +25,20 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - /** - * Created by Stefan Herndler. - * User: Stefan - * Date: 15.05.14 - * Time: 16:21 - * Version: 1.1.1 - * Since: 1.0 + * @filesource + * @author Stefan Herndler + * @since 0.0.1 */ -// include constants -require_once(dirname(__FILE__) . "/includes/defines.php"); -// include language functions -require_once(dirname(__FILE__) . "/includes/language.php"); -// include storage functions and global plugin functions -require_once(dirname(__FILE__) . "/includes/plugin-settings.php"); +// Get all common classes and functions +require_once(dirname(__FILE__) . "/includes.php"); -// require plugin class -require_once(dirname( __FILE__ ) . "/classes/footnotes.php"); - - -// initialize an object of the plugin class -global $g_obj_MCI_Footnotes; -// if object isn't initialized yet, initialize it now -if (empty($g_obj_MCI_Footnotes)) { - $g_obj_MCI_Footnotes = new MCI_Footnotes(); -} -// generate the settings page in the dashboard settings -$g_obj_MCI_Footnotes->generateLayout(); - -// register hook for activating the plugin -register_activation_hook(__FILE__, array('MCI_Footnotes', 'activate')); -// register hook for deactivating the plugin -register_deactivation_hook(__FILE__, array('MCI_Footnotes', 'deactivate')); - -// only admin is allowed to execute the following functions -if (!function_exists('is_admin')) { - header('Status: 403 Forbidden'); - header('HTTP/1.1 403 Forbidden'); - exit(); -} - -// register hook for uninstalling the plugin -register_uninstall_hook(__FILE__, array('MCI_Footnotes', 'uninstall')); +// add Plugin Links to the "installed plugins" page +$l_str_plugin_file = 'footnotes/index.php'; +add_filter("plugin_action_links_{$l_str_plugin_file}", array("MCI_Footnotes_Hooks", "PluginLinks"), 10, 2); +// initialize the Plugin +$g_obj_MCI_Footnotes = new MCI_Footnotes(); +// run the Plugin +$g_obj_MCI_Footnotes->run(); \ No newline at end of file diff --git a/js/wysiwyg-editor.js b/js/wysiwyg-editor.js index d1711ab..f4417bd 100644 --- a/js/wysiwyg-editor.js +++ b/js/wysiwyg-editor.js @@ -24,8 +24,7 @@ type: 'POST', url: '/wp-admin/admin-ajax.php', data: { - action: 'footnotes_getTags', - data: '' + action: 'footnotes_getTags' }, success: function(data, textStatus, XMLHttpRequest){ var l_arr_Tags = JSON.parse(data); @@ -62,15 +61,15 @@ */ getInfo : function() { return { - longname : 'insert footnotes tag', - author : 'media competence institute', - authorurl : 'http://cheret.co.uk/mci', + longname : 'Inserts the Footnotes short code.', + author : 'ManFisher Medien ManuFaktur', + authorurl : 'http://http://manfisher.net/', infourl : 'http://wordpress.org/plugins/footnotes/', - version : "1.2.0" + version : "1.5.0" }; } }); // Register plugin - tinymce.PluginManager.add( 'footnotes', tinymce.plugins.Footnotes ); + tinymce.PluginManager.add('footnotes', tinymce.plugins.Footnotes); })(); \ No newline at end of file diff --git a/readme.txt b/readme.txt index 588817b..90fde87 100755 --- a/readme.txt +++ b/readme.txt @@ -72,6 +72,13 @@ Visit this swift write-up from a **footnotes** user by the name of **Southwest** == Changelog == += 1.5.0 = +- Update: Refactored the whole source code +- Add: Grouped the Plugin Settings into a new Menu Page called "ManFisher Plugins" +- Update: Moved the Diagnostics Sections to into a new Sub Page called "Diagnostics" +- Add: Sub Page to list all other Plugins of the Contributors +- Bugfix: Line up Footnotes with multiple lines in the Reference container + = 1.4.0 = - Feature: WPML Config XML file for easy multi language string translation (WPML String Translation Support File) - Update: Changed e-Mail support address to the WordPress support forum diff --git a/templates/container.html b/templates/container.html deleted file mode 100755 index 8b86104..0000000 --- a/templates/container.html +++ /dev/null @@ -1,8 +0,0 @@ -
-
[[FOOTNOTE INDEX]].
-
- [[HYPERLINK SYMBOL]] [[FOOTNOTE TEXT]]
-
-
\ No newline at end of file diff --git a/templates/dashboard/customize-css.html b/templates/dashboard/customize-css.html new file mode 100644 index 0000000..72a005f --- /dev/null +++ b/templates/dashboard/customize-css.html @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[[label-css]][[css]]
[[headline]]
[[label-class-1]][[class-1]]
[[label-class-2]][[class-2]]
[[label-class-3]][[class-3]]
[[label-class-4]][[class-4]]
[[label-class-5]][[class-1]]
\ No newline at end of file diff --git a/templates/dashboard/customize-hyperlink-arrow.html b/templates/dashboard/customize-hyperlink-arrow.html new file mode 100644 index 0000000..6a0fdfa --- /dev/null +++ b/templates/dashboard/customize-hyperlink-arrow.html @@ -0,0 +1,12 @@ + + + + + + + + + + + +
[[label-symbol]][[symbol]]
[[label-user-defined]][[user-defined]]
[[comment]]
\ No newline at end of file diff --git a/templates/dashboard/customize-superscript.html b/templates/dashboard/customize-superscript.html new file mode 100644 index 0000000..fb80826 --- /dev/null +++ b/templates/dashboard/customize-superscript.html @@ -0,0 +1,12 @@ + + + + + + + + + + + +
[[label-before]][[before]]
[[label-after]][[after]]
\ No newline at end of file diff --git a/templates/dashboard/diagnostics.html b/templates/dashboard/diagnostics.html new file mode 100644 index 0000000..982c2e5 --- /dev/null +++ b/templates/dashboard/diagnostics.html @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + [[plugins]] + +
[[label-server]][[server]]
[[label-php]][[php]]
[[label-max-execution-time]][[max-execution-time]]
[[label-memory-limit]][[memory-limit]]
[[label-php-extensions]][[php-extensions]]
[[label-wordpress]][[wordpress]]
\ No newline at end of file diff --git a/templates/dashboard/editor-button.html b/templates/dashboard/editor-button.html new file mode 100644 index 0000000..df47ef5 --- /dev/null +++ b/templates/dashboard/editor-button.html @@ -0,0 +1,42 @@ + \ No newline at end of file diff --git a/templates/dashboard/how-to-donate.html b/templates/dashboard/how-to-donate.html new file mode 100644 index 0000000..97c825b --- /dev/null +++ b/templates/dashboard/how-to-donate.html @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/templates/dashboard/how-to-help.html b/templates/dashboard/how-to-help.html new file mode 100644 index 0000000..5a9acce --- /dev/null +++ b/templates/dashboard/how-to-help.html @@ -0,0 +1,13 @@ +
+ [[label-start]] [[start]] +
+ [[label-end]] [[end]] +
+ +
+ [[example-code]][[example-string]]    [[example]] +
+ +
+ [[information]] +
\ No newline at end of file diff --git a/templates/dashboard/other-plugins.html b/templates/dashboard/other-plugins.html new file mode 100644 index 0000000..86c9c0c --- /dev/null +++ b/templates/dashboard/other-plugins.html @@ -0,0 +1,42 @@ +
+
+
+

[[title]]

+
+ +
+

+
+
+
+

+
+
+ \ No newline at end of file diff --git a/templates/dashboard/settings-love.html b/templates/dashboard/settings-love.html new file mode 100644 index 0000000..70dd4f2 --- /dev/null +++ b/templates/dashboard/settings-love.html @@ -0,0 +1,12 @@ + + + + + + + + + + + +
[[label-love]][[love]]
[[label-no-love]][[no-love]]
\ No newline at end of file diff --git a/templates/dashboard/settings-other.html b/templates/dashboard/settings-other.html new file mode 100644 index 0000000..9e2a1eb --- /dev/null +++ b/templates/dashboard/settings-other.html @@ -0,0 +1,8 @@ + + + + + + + +
[[label-excerpt]][[excerpt]]
\ No newline at end of file diff --git a/templates/dashboard/settings-reference-container.html b/templates/dashboard/settings-reference-container.html new file mode 100644 index 0000000..37e950d --- /dev/null +++ b/templates/dashboard/settings-reference-container.html @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + +
[[label-name]][[name]]
[[label-collapse]][[collapse]]
[[label-position]][[position]]
\ No newline at end of file diff --git a/templates/dashboard/settings-styling.html b/templates/dashboard/settings-styling.html new file mode 100644 index 0000000..f81c780 --- /dev/null +++ b/templates/dashboard/settings-styling.html @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[[label-identical]][[identical]]
[[label-short-code-start]][[short-code-start]]
[[label-short-code-end]][[short-code-end]]
[[label-short-code-start-user]][[short-code-start-user]]
[[label-short-code-end-user]][[short-code-end-user]]
[[label-counter-style]][[counter-style]]
+ \ No newline at end of file diff --git a/templates/footnote.html b/templates/footnote.html deleted file mode 100755 index bd808ad..0000000 --- a/templates/footnote.html +++ /dev/null @@ -1,22 +0,0 @@ -[[FOOTNOTE BEFORE]][[FOOTNOTE INDEX]][[FOOTNOTE AFTER]] - - - [[FOOTNOTE TEXT]] - - - \ No newline at end of file diff --git a/templates/public/footnote.html b/templates/public/footnote.html new file mode 100755 index 0000000..35de087 --- /dev/null +++ b/templates/public/footnote.html @@ -0,0 +1,14 @@ +[[before]][[index]][[after]] +[[text]] + \ No newline at end of file diff --git a/templates/public/reference-container-body.html b/templates/public/reference-container-body.html new file mode 100755 index 0000000..c82a747 --- /dev/null +++ b/templates/public/reference-container-body.html @@ -0,0 +1,7 @@ + + [[index]]. + [[arrow]] + [[text]] + \ No newline at end of file diff --git a/templates/public/reference-container.html b/templates/public/reference-container.html new file mode 100644 index 0000000..4b41c91 --- /dev/null +++ b/templates/public/reference-container.html @@ -0,0 +1,26 @@ +
+

[[label]][[buttons]]

+
+
+ + + [[content]] + +
+
+ + \ No newline at end of file