- Add: Setting to enable an excerpt of the Footnotes mouse-over box text (default: disabled)
- Add: Setting to define the maximum length of the excerpt displayed in the mouse-over box (default: 150 characters) - Update: Detail information about other Plugins from ManFisher (rating, downloads, last updated, Author name/url) - Update: Receiving list of other Plugins from the Developer Team from an external server - Update: Translations (EN and DE) - Bugfix: Removed hard coded position of the 'ManFisher' main menu page (avoid errors with other Plugins) - Bugfix: Changed function name (includes.php) to be unique (avoid errors with other Plugins) - Bugfix: Try to replace each appearance of Footnotes in the current Post object loaded from the WordPress database git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@1003242 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
parent
6a4677251a
commit
e054849b1e
17 changed files with 328 additions and 122 deletions
|
@ -114,7 +114,7 @@ class MCI_Footnotes_Layout_Init {
|
|||
self::C_STR_MAIN_MENU_SLUG, // menu slug
|
||||
array($this, "displayOtherPlugins"), // function
|
||||
plugins_url('footnotes/img/main-menu.png'), // icon url
|
||||
81 // position
|
||||
null // position
|
||||
);
|
||||
$this->registerSubPages();
|
||||
}
|
||||
|
@ -149,9 +149,9 @@ class MCI_Footnotes_Layout_Init {
|
|||
printf('<em>visit <a href="http://manfisher.net/" target="_blank">ManFisher Medien ManuFaktur</a> or <a href="http://herndler.org" target="_blank">herndler.org</a></em>');
|
||||
printf("<br/><br/>");
|
||||
printf("<h3>%s</h3>", __('Take a look on other Plugins we have developed.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
|
||||
/*
|
||||
|
||||
// collect plugin list as JSON
|
||||
$l_arr_Response = wp_remote_get("http://herndler.org/wordpress/plugins/get.json");
|
||||
$l_arr_Response = wp_remote_get("http://herndler.org/project/other-wordpress-plugins.php");
|
||||
// check if response is valid
|
||||
if (is_wp_error($l_arr_Response)) {
|
||||
printf(__("Error loading other WordPress Plugins from Manfisher. Sorry!", MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
|
||||
|
@ -161,13 +161,6 @@ class MCI_Footnotes_Layout_Init {
|
|||
$l_str_Response = $l_arr_Response["body"];
|
||||
// convert the body to a json string
|
||||
$l_arr_Plugins = json_decode($l_str_Response, true);
|
||||
*/
|
||||
$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" => "footnotes", "title" => "Footnotes")
|
||||
);
|
||||
|
||||
// load template file
|
||||
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "other-plugins");
|
||||
|
@ -178,8 +171,13 @@ class MCI_Footnotes_Layout_Init {
|
|||
// replace Plugin information
|
||||
$l_obj_Template->replace(
|
||||
array(
|
||||
"name" => $l_arr_PluginInfo["name"],
|
||||
"title" => $l_arr_PluginInfo["title"]
|
||||
"server" => ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://" . $_SERVER["SERVER_NAME"],
|
||||
"plugin-name" => $l_arr_PluginInfo["name"],
|
||||
"plugin-title" => $l_arr_PluginInfo["title"],
|
||||
"plugin-icon" => "http://plugins.svn.wordpress.org/" . $l_arr_PluginInfo["name"] ."/assets/icon-256x256.png",
|
||||
"install-label" => __("Install now", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
||||
"more-details-label" => __("More Details", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
||||
"last-updated-label" => __("Last Updated", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)
|
||||
)
|
||||
);
|
||||
// display Plugin
|
||||
|
@ -220,18 +218,29 @@ class MCI_Footnotes_Layout_Init {
|
|||
// get plugin object
|
||||
$l_arr_Plugin = json_decode($l_str_Response, true);
|
||||
if (empty($l_arr_Plugin)) {
|
||||
echo json_encode(array("error" => "Error reading Plugin meta information."));
|
||||
echo json_encode(array("error" => "Error reading Plugin meta information.<br/>URL: " . $l_str_Url . "<br/>Response: " . $l_str_Response));
|
||||
exit;
|
||||
}
|
||||
|
||||
$l_int_NumRatings = array_key_exists("num_ratings", $l_arr_Plugin) ? intval($l_arr_Plugin["num_ratings"]) : 0;
|
||||
$l_int_Rating = array_key_exists("rating", $l_arr_Plugin) ? floatval($l_arr_Plugin["rating"]) : 0.0;
|
||||
$l_int_Stars = round(5 * $l_int_Rating / 100.0, 1);
|
||||
|
||||
// return Plugin information as JSON encoded string
|
||||
echo json_encode(
|
||||
array(
|
||||
"error" => "",
|
||||
"PluginImage" => "",
|
||||
"PluginDescription" => array_key_exists("short_description", $l_arr_Plugin) ? html_entity_decode($l_arr_Plugin["short_description"]) : "Error reading Plugin information",
|
||||
"PluginUrl" => array_key_exists("homepage", $l_arr_Plugin) ? $l_arr_Plugin["homepage"] : "",
|
||||
"PluginVersion" => array_key_exists("version", $l_arr_Plugin) ? $l_arr_Plugin["version"] : "---"
|
||||
"PluginAuthor" => array_key_exists("author", $l_arr_Plugin) ? html_entity_decode($l_arr_Plugin["author"]) : "unknown",
|
||||
"PluginRatingText" => $l_int_Stars . " " . __("rating based on", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . " " . $l_int_NumRatings . " " . __("ratings", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
||||
"PluginRating1" => $l_int_NumRatings >= 0.5 ? "star-full" : "star-empty",
|
||||
"PluginRating2" => $l_int_NumRatings >= 1.5 ? "star-full" : "star-empty",
|
||||
"PluginRating3" => $l_int_NumRatings >= 2.5 ? "star-full" : "star-empty",
|
||||
"PluginRating4" => $l_int_NumRatings >= 3.5 ? "star-full" : "star-empty",
|
||||
"PluginRating5" => $l_int_NumRatings >= 4.5 ? "star-full" : "star-empty",
|
||||
"PluginRating" => $l_int_NumRatings,
|
||||
"PluginLastUpdated" => array_key_exists("last_updated", $l_arr_Plugin) ? $l_arr_Plugin["last_updated"] : "unknown",
|
||||
"PluginDownloads" => array_key_exists("downloaded", $l_arr_Plugin) ? $l_arr_Plugin["downloaded"] : "---"
|
||||
)
|
||||
);
|
||||
exit;
|
||||
|
|
|
@ -113,6 +113,9 @@ class MCI_Footnotes_Layout_Diagnostics extends MCI_Footnotes_LayoutEngine {
|
|||
"label-php" => __("PHP version", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
||||
"php" => phpversion(),
|
||||
|
||||
"label-user-agent" => __("User agent", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
|
||||
"user-agent" => $_SERVER["HTTP_USER_AGENT"],
|
||||
|
||||
"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),
|
||||
|
||||
|
|
|
@ -290,6 +290,10 @@ class MCI_Footnotes_Layout_Settings extends MCI_Footnotes_LayoutEngine {
|
|||
array(
|
||||
"label-enable" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED, __("Enable the mouse-over box", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
|
||||
"enable" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED, $l_arr_Enabled),
|
||||
"label-activate-excerpt" => $this->addLabel(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED, __("Display only an excerpt", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
|
||||
"activate-excerpt" => $this->addSelectBox(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED, $l_arr_Enabled),
|
||||
"label-excerpt-length" => $this->addLabel(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH, __("Maximum characters for the excerpt", MCI_Footnotes_Config::C_STR_PLUGIN_NAME)),
|
||||
"excerpt-length" => $this->addTextBox(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH)
|
||||
)
|
||||
);
|
||||
// display template with replaced placeholders
|
||||
|
|
|
@ -144,6 +144,24 @@ class MCI_Footnotes_Settings {
|
|||
*/
|
||||
const C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED = "footnote_inputfield_custom_mouse_over_box_enabled";
|
||||
|
||||
/**
|
||||
* Settings Container Key for the mouse-over box to display only an excerpt.
|
||||
*
|
||||
* @author Stefan Herndler
|
||||
* @since 1.5.4
|
||||
* @var string
|
||||
*/
|
||||
const C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED = "footnote_inputfield_custom_mouse_over_box_excerpt_enabled";
|
||||
|
||||
/**
|
||||
* Settings Container Key for the mouse-over box to define the max. length of the enabled expert.
|
||||
*
|
||||
* @author Stefan Herndler
|
||||
* @since 1.5.4
|
||||
* @var string
|
||||
*/
|
||||
const C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH = "footnote_inputfield_custom_mouse_over_box_excerpt_length";
|
||||
|
||||
/**
|
||||
* Settings Container Key for the Hyperlink arrow.
|
||||
*
|
||||
|
@ -214,6 +232,8 @@ class MCI_Footnotes_Settings {
|
|||
self::C_STR_FOOTNOTES_STYLING_BEFORE => '',
|
||||
self::C_STR_FOOTNOTES_STYLING_AFTER => ')',
|
||||
self::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED => 'yes',
|
||||
self::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED => 'no',
|
||||
self::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH => 150,
|
||||
self::C_STR_HYPERLINK_ARROW => '↑',
|
||||
self::C_STR_HYPERLINK_ARROW_USER_DEFINED => '',
|
||||
self::C_STR_CUSTOM_CSS => ''
|
||||
|
|
|
@ -59,6 +59,9 @@ class MCI_Footnotes_Task {
|
|||
|
||||
// replace footnotes in the content of a widget
|
||||
add_filter('widget_text', array($this, "WidgetText"), PHP_INT_MAX);
|
||||
|
||||
// replace footnotes in the Post object after receiving it from the database
|
||||
add_action('the_post', array($this, "manipulatePostObject"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -164,6 +167,19 @@ class MCI_Footnotes_Task {
|
|||
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 each Content var of the current Post object.
|
||||
*
|
||||
* @author Stefan Herndler
|
||||
* @since 1.5.4
|
||||
* @param WP_Post $p_obj_Post
|
||||
*/
|
||||
public function manipulatePostObject(&$p_obj_Post) {
|
||||
$p_obj_Post->post_content = $this->exec($p_obj_Post->post_content);
|
||||
$p_obj_Post->post_content_filtered = $this->exec($p_obj_Post->post_content_filtered);
|
||||
$p_obj_Post->post_excerpt = $this->exec($p_obj_Post->post_excerpt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all footnotes that occur in the given content.
|
||||
*
|
||||
|
@ -258,11 +274,25 @@ class MCI_Footnotes_Task {
|
|||
// display the footnote as mouse-over box
|
||||
if (!$p_bool_HideFootnotesText) {
|
||||
$l_str_Index = MCI_Footnotes_Convert::Index($l_int_FootnoteIndex, MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_COUNTER_STYLE));
|
||||
|
||||
// display only an excerpt of the footnotes text if enabled
|
||||
$l_str_ExcerptText = $l_str_FootnoteText;
|
||||
$l_bool_EnableExcerpt = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_ENABLED));
|
||||
$l_int_MaxLength = intval(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_INT_FOOTNOTES_MOUSE_OVER_BOX_EXCERPT_LENGTH));
|
||||
if ($l_bool_EnableExcerpt) {
|
||||
$l_str_FootnoteText = strip_tags($l_str_FootnoteText);
|
||||
if (is_int($l_int_MaxLength) && strlen($l_str_FootnoteText) > $l_int_MaxLength) {
|
||||
$l_str_ExcerptText = substr($l_str_FootnoteText, 0, $l_int_MaxLength);
|
||||
$l_str_ExcerptText = substr($l_str_ExcerptText, 0, strrpos($l_str_ExcerptText, ' '));
|
||||
$l_str_ExcerptText .= " ..." . sprintf(__("%scontinue%s", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), '<a href="" onclick="footnote_moveToAnchor(\'footnote_plugin_reference_'.$l_str_Index.'\');">', '</a>');
|
||||
}
|
||||
}
|
||||
|
||||
// fill the footnotes template
|
||||
$l_obj_Template->replace(
|
||||
array(
|
||||
"index" => $l_str_Index,
|
||||
"text" => MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED)) ? $l_str_FootnoteText : "",
|
||||
"text" => MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED)) ? $l_str_ExcerptText : "",
|
||||
"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)
|
||||
)
|
||||
|
|
Reference in a new issue