Skip to content

Commit

Permalink
deprecate old stuff, rm files, simplify settings screens
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Taggart committed Oct 12, 2016
1 parent 07fe210 commit eb0b00c
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 6,746 deletions.
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,25 @@ Provides a library of additional template tags, 3rd-party libraries, and functio
# Changelog:

## 1.1
- Deprecated pickadate.js library
- Add PHP.ini file to sysinfo
- Add fn `mapi_query_related()`
- Add fn `mapi_get_active_template()`
- Rewrite `mapi_money_format()` with trim zeros
- Rewrite `mapi_excerpt()` with improved CPT/ACF support
- Fix 'http' google font link on maintenance mode screen
- Update copyright date and name
- Updated `mapi_facebook_lookup()` to use an Open Graph access token
- Migrated TGM Plugin activation and Twitter PHP API SDK to Composer
- Add `mapi_facebook_posts()` function
- Deprecate `mapi_facebook_rss()` function
- Add `mapi_post_exists()` function
- Add fn `mapi_get_active_template()`
- Add fn `mapi_query_related()`
- Add function for responsive video embeds, `mapi_embed_html()`
- Add PHP.ini file to sysinfo
- Added Google, Gravity Forms and Tribe plugins to the default exclusion list for minification",
- Change IE update nag to version 11
- Deprecate `mapi_facebook_rss()` function
- Deprecated pickadate.js and many older 3rd party libraries
- Disable WordPress 4.2+ inline support for Emojis (removed inline CSS/JS code from head, toggleable)
- Fix 'http' google font link on maintenance mode screen
- Migrated TGM Plugin activation and Twitter PHP API SDK to Composer
- Remove deprecated `get_currentuserinfo()` calls
- Remove deprecated params from TGMPA
- Rewrite `mapi_excerpt()` with improved CPT/ACF support
- Rewrite `mapi_money_format()` with trim zeros
- Update copyright date and name
- Updated `mapi_facebook_lookup()` to use an Open Graph access token

## 1.0.1
- Premissions fix for mThumb
Expand Down
78 changes: 30 additions & 48 deletions controllers/mapi-options-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ public function set_error_display_options() {
*/
public function set_script_options() {

if (@$this->options[ 'fix_console' ]) {
add_action('wp_head', 'mapi_fix_console', 1);
}

if (!empty($this->options[ 'enable_adv_speed_options' ]) && !is_admin()) {
if (!empty($this->options[ 'enable_adv_speed_options' ][ 'dequeue_scripts_txt' ])) {
add_action('wp_enqueue_scripts', 'mapi_dequeue_scripts', 100);
Expand All @@ -75,7 +71,6 @@ public function set_script_options() {
add_action('wp_enqueue_scripts', 'mapi_enqueue_scripts', 100);
}
}

if (@$this->options[ 'load_jquery' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_jquery');
}
Expand All @@ -100,30 +95,15 @@ public function set_script_options() {
if (@$this->options[ 'load_leaflet_js' ] || @$this->options[ 'load_mapbox_js' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_mapbox', 100); // leaflet replaced by mapbox
}
if (@$this->options[ 'load_retina_js' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_retina', 100);
}
if (@$this->options[ 'load_swfobject_js' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_swfobject', 100);
}
if (@$this->options[ 'load_masonry_js' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_masonry', 100);
}
if (@$this->options[ 'load_isotope_js' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_isotope', 100);
}
if (@$this->options[ 'load_superfish_js' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_superfish', 100);
}
if (@$this->options[ 'load_bbq' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_bbq', 100);
}
if (@$this->options[ 'load_tiptip_js' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_tiptip', 100);
}
if (@$this->options[ 'load_lettering_js' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_lettering', 100);
}
if (@$this->options[ 'load_fittext_js' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_fittext', 100);
}
Expand All @@ -133,20 +113,9 @@ public function set_script_options() {
if (@$this->options[ 'load_flexslider' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_flexslider', 100);
}
if (@$this->options[ 'load_replacetext_js' ]) {
add_action('wp_head', 'mapi_replacetext_js', 100);
}
if (@$this->options[ 'load_search_highlighter_js' ]) {
add_action('wp_head', 'mapi_query', 5); // set query string as js variable in header, used to highlight search terms
add_action('wp_head', 'mapi_search_highlighter_js', 100);
}
if (@$this->options[ 'load_easylistsplitter_js' ]) {
add_action('wp_head', 'mapi_load_easylistsplitter', 100);
}
if (@$this->options[ 'load_tinysort_js' ]) {
add_action('wp_head', 'mapi_load_tinysort', 100);
}

if (@$this->options[ 'load_ieupdate' ] === TRUE || mapi_is_true(@$this->options[ 'load_ieupdate' ][ 'enabled' ])) {
if (@empty($this->options[ 'load_ieupdate_version_txt' ])) {
$this->options[ 'load_ieupdate_version_txt' ] = 10;
Expand Down Expand Up @@ -175,10 +144,34 @@ public function set_script_options() {
add_action('wp_enqueue_scripts', 'mapi_js', 100);
}

// DEPRECATED LIBRARIES AND SETTINGS
/**
* DEPRECATED LIBRARIES AND SETTINGS (left for backward compatibility):
*/
if (@$this->options[ 'load_superfish_js' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_superfish', 100);
}
if (@$this->options[ 'load_swfobject_js' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_swfobject', 100);
}
if (@$this->options[ 'load_replacetext_js' ]) {
add_action('wp_head', 'mapi_replacetext_js', 100);
}
if (@$this->options[ 'load_lettering_js' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_lettering', 100);
}
if (@$this->options[ 'load_pickadate_js' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_pickadate', 100);
}
if (@$this->options[ 'load_retina_js' ]) {
add_action('wp_enqueue_scripts', 'mapi_load_retina', 100);
}
if (@$this->options[ 'load_easylistsplitter_js' ]) {
add_action('wp_head', 'mapi_load_easylistsplitter', 100);
}
if (@$this->options[ 'menu_sort_reverse' ]) {
// force nav menus to all display in the correct order
add_filter('wp_nav_menu_objects', create_function('$menu', 'return array_reverse(array_reverse($menu ));'));
}
}

/**
Expand Down Expand Up @@ -230,32 +223,21 @@ public function set_misc_options() {
add_filter($filter, 'mapi_encode_emails', 100);
}
}

if (@$this->options[ 'set_admin_color_scheme' ]) {
add_filter('get_user_option_admin_color', 'mapi_set_admin_color_scheme', 5);
}

if (@$this->options[ 'enabled_htmlawed' ]) {
add_filter('the_content', 'mapi_html_cleanup');
}

if (@$this->options[ 'suppress_login_errors' ]) {
add_filter('login_errors', '__return_false'); // disable login errors
}

if (@$this->options[ 'auto_remove_large_images' ]) {
add_filter('wp_generate_attachment_metadata', 'mapi_remove_large_image');
}

if (@$this->options[ 'menu_sort_reverse' ]) {
// force nav menus to all display in the correct order
add_filter('wp_nav_menu_objects', create_function('$menu', 'return array_reverse(array_reverse($menu ));'));
}

if (@$this->options[ 'remove_recent_comments_style' ]) {
add_action('widgets_init', 'mapi_remove_recent_comments_style'); //[E]
}

if (!empty($this->options[ 'excerpt_more_txt' ])) {
add_filter('excerpt_more', 'mapi_excerpt_more'); // change default more suffix from [...] to ...
}
Expand Down Expand Up @@ -322,24 +304,24 @@ public function set_misc_options() {
add_filter('embed_oembed_html', 'mapi_embed_html', 10, 3);
add_filter('video_embed_html', 'mapi_embed_html'); // Jetpack

remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'start_post_rel_link');
remove_action('wp_head', 'wlwmanifest_link');

add_filter('the_generator', '__return_false'); // hide the WP version
add_filter('gform_enable_field_label_visibility_settings', '__return_true'); // enable gforms visibility settings
remove_action('wp_head', 'wp_generator');
add_filter('gform_enable_field_label_visibility_settings', '__return_true'); // enable gforms visibility settings

add_filter('body_class', 'mapi_add_body_classes'); // add classes to body tag
add_filter('body_class', 'mapi_add_os_body_class');

// allow login by email or username
remove_filter('authenticate', 'wp_authenticate_username_password', 20, 3);
remove_filter('authenticate', 'wp_authenticate_username_password', 20);
add_filter('authenticate', 'mapi_email_login_authenticate', 20, 3);
add_action('login_form', 'mapi_username_or_email_login');

Expand Down
103 changes: 100 additions & 3 deletions core/deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ function mapi_less() {
*/
function mapi_js() {
_deprecated_function(__FUNCTION__, '3.8');
wp_deregister_script('mapi_js');
wp_register_script('mapi_js', plugins_url('js/mapi.js', dirname(__FILE__)));
wp_enqueue_script('mapi_js');
}

/**
Expand Down Expand Up @@ -306,6 +303,7 @@ function mapi_list_children_menu() {
* @deprecated
*/
function mapi_load_pickadate() {
_deprecated_function(__FUNCTION__, '4.6');
if (!is_admin()) {
wp_deregister_script('pickadate');
wp_register_script('pickadate', '//cdn.jsdelivr.net/jquery.pickadate.js/4.0.0-0/ui-pickadate.min.js', array('jquery'));
Expand All @@ -324,3 +322,102 @@ function mapi_load_pickadate() {
wp_enqueue_style('pickadate-css');
}
}

/**
* Loads Retina
*
* @deprecated
*/
function mapi_load_retina() {
_deprecated_function(__FUNCTION__, '4.6');
if (!is_admin()) {
wp_deregister_script('retina');
wp_register_script('retina', '//cdn.jsdelivr.net/retinajs/1.3.0/retina.min.js');
wp_enqueue_script('retina');
}
}

/**
* Loads jQuery BBQ
*
* @deprecated
*/
function mapi_load_bbq() {
_deprecated_function(__FUNCTION__, '4.6');
}

/**
* Loads easyListSplitter
*
* @deprecated
*/
function mapi_load_easylistsplitter() {
_deprecated_function(__FUNCTION__, '4.6');
if (!is_admin()) {
wp_deregister_script('easylistsplitter');
wp_register_script('easylistsplitter', '//cdn.jsdelivr.net/easylistsplitter/1.0.2/jquery.easyListSplitter.js', array('jquery'));
wp_enqueue_script('easylistsplitter');
}
}

/**
* Loads Lettering
*
* @deprecated
*/
function mapi_load_lettering() {
_deprecated_function(__FUNCTION__, '4.6');
if (!is_admin()) {
wp_deregister_script('lettering');
wp_register_script('lettering', '//cdn.jsdelivr.net/lettering/0.7.0/jquery.lettering.min.js', array('jquery'));
wp_enqueue_script('lettering');
}
}

/**
* Loads jQuery ReplaceText plguin.
*
* @deprecated
*/
function mapi_replacetext_js() {
_deprecated_function(__FUNCTION__, '4.6');
}

/**
* Loads JavaScript to automatically highlight search terms on WordPress search results pages.
*
* @deprecated
*/
function mapi_search_highlighter_js() {
_deprecated_function(__FUNCTION__, '4.6');
}

/**
* Prevents JavaScript errors if the console object is not defined.
*
* @deprecated
*/
function mapi_fix_console() {
_deprecated_function(__FUNCTION__, '4.6');
}

/**
* Loads SWFObject
*
* @deprecated
*/
function mapi_load_swfobject() {
_deprecated_function(__FUNCTION__, '4.6');
if (!is_admin()) {
wp_enqueue_script('swfobject');
}
}

/**
* Not intended for general use in themes. Get query variables. Used to highlight search terms via JavaScript.
*
* @deprecated
*/
function mapi_query() {
_deprecated_function(__FUNCTION__, '4.6');
}
27 changes: 1 addition & 26 deletions core/mapi-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

/**
*
* Not intended for general use in themes. Gets the current search term (to be used in JavaScript).
* Gets the current search term (to be used in JavaScript).
*
* @return mixed
*/
Expand All @@ -34,31 +34,6 @@ function mapi_get_search_query() {
}
}

/**
*
* Not intended for general use in themes. Get query variables. Used to highlight search terms via JavaScript.
*
*/
function mapi_query() {
global $mapi_do_extend;

$areas = apply_filters('mapi_search_highlight_containers', array('div.page', 'div.post', 'article.page', 'article.post')); // Using the tag 'body' is known to cause conflicts
// js >> var mapi_ids = new Array("'.$id'","#main","#wrapper");
$terms = mapi_get_search_query();
$filtered = array();
if($terms) {
foreach($terms as $term) {
$term = esc_attr(trim(str_replace(array('"', '\'', '%22'), '', $term)));
if(!empty($term)) {
$filtered[] = '"' . $term . '"';
}
}
if(count($filtered) > 0) {
$mapi_do_extend = TRUE;
echo '<script type="text/javascript">var mapi_query = new Array(' . implode(',', $filtered) . ');var mapi_areas = new Array("' . implode('","', $areas) . '");</script>';
}
}
}

/**
* Replaces the GET variable 's' with a nice URL, like 'search'.
Expand Down
Loading

0 comments on commit eb0b00c

Please sign in to comment.