diff --git a/Gruntfile.js b/Gruntfile.js index 3a05a97..fbcb2e0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -15,15 +15,6 @@ module.exports = function(grunt) { options: { livereload: true }, files: ['public/assets/**/*', '**/*.html', '**/*.php', 'public/assets/img/**/*.{png,jpg,jpeg,gif,webp,svg}'] } - }, - concat: { - dist: { - src: [ - 'public/assets/js/source/util--wp-api.js', - 'public/assets/js/source/wp-search.js' - ], - dest: 'public/assets/js/wp-search.js' - } }, compass: { dist: { diff --git a/README.txt b/README.txt index 0e12528..967927a 100755 --- a/README.txt +++ b/README.txt @@ -1,7 +1,7 @@ === WP Live Search === Contributors: nphaskins Author URI: http://nickhaskins.com -Plugin URI: http://nickhaskins.com/wp-search +Plugin URI: http://nickhaskins.com/wpls Tags: search, live search Requires at least: 3.5.1 Tested up to: 4.2.1 diff --git a/package.json b/package.json index f72b3e8..e7fd149 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "wp-search", + "name": "wpls", "version": "0.0.1", "dependencies": { "load-grunt-tasks": "~0.2.1" diff --git a/public/assets/css/style.css b/public/assets/css/style.css index b518a27..0389c93 100644 --- a/public/assets/css/style.css +++ b/public/assets/css/style.css @@ -1 +1 @@ -.wp-search--loading{height:20px;width:20px;position:absolute;top:0;right:10px;opacity:0}.wp-search--loader{height:20px;width:20px;margin:10px auto;position:relative;-webkit-animation:rotation .6s infinite linear;-moz-animation:rotation .6s infinite linear;-o-animation:rotation .6s infinite linear;animation:rotation .6s infinite linear;border-left:3px solid rgba(216,216,216,0.5);border-right:3px solid rgba(216,216,216,0.5);border-bottom:3px solid rgba(216,216,216,0.5);border-top:3px solid #d8d8d8;border-radius:100%}@-webkit-keyframes rotation{from{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(359deg)}}@-moz-keyframes rotation{from{-moz-transform:rotate(0deg)}to{-moz-transform:rotate(359deg)}}@-o-keyframes rotation{from{-o-transform:rotate(0deg)}to{-o-transform:rotate(359deg)}}@keyframes rotation{from{transform:rotate(0deg)}to{transform:rotate(359deg)}}.wp-search--results-wrap{opacity:0}#wp-search--input-wrap{position:relative}#wp-search--input{height:40px}#wp-search--post-list{list-style:none;margin:0;padding:0;background:#EAEAEA}#wp-search--post-list li{padding:0;margin:0}#wp-search--post-list a{line-height:1;display:block;text-decoration:none;border:none;padding:10px}#wp-search--post-list .wp-search--item-title{margin:5px auto}.wp-search--link{*zoom:1}.wp-search--link:before,.wp-search--link:after{content:" ";display:table}.wp-search--link:after{clear:both}.wp-search--link:hover{background:#f4f4f4}.wp-search--item-image{float:left;max-width:40px;margin-right:10px}.wp-search--item-title{display:inline-block;overflow:hidden;width:auto}#wp-search--helper{position:absolute;right:7px;top:7px;font-size:13px;padding:3px 8px;background:#5bc0de;color:white;border-radius:2px;font-family:Arial} +.wpls--loading{height:20px;width:20px;position:absolute;top:0;right:10px;opacity:0}.wpls--loader{height:20px;width:20px;margin:10px auto;position:relative;-webkit-animation:rotation .6s infinite linear;-moz-animation:rotation .6s infinite linear;-o-animation:rotation .6s infinite linear;animation:rotation .6s infinite linear;border-left:3px solid rgba(216,216,216,0.5);border-right:3px solid rgba(216,216,216,0.5);border-bottom:3px solid rgba(216,216,216,0.5);border-top:3px solid #d8d8d8;border-radius:100%}@-webkit-keyframes rotation{from{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(359deg)}}@-moz-keyframes rotation{from{-moz-transform:rotate(0deg)}to{-moz-transform:rotate(359deg)}}@-o-keyframes rotation{from{-o-transform:rotate(0deg)}to{-o-transform:rotate(359deg)}}@keyframes rotation{from{transform:rotate(0deg)}to{transform:rotate(359deg)}}.wpls--results-wrap{opacity:0}#wpls--input-wrap{position:relative}#wpls--input{height:40px}#wpls--post-list{list-style:none;margin:0;padding:0;background:#EAEAEA}#wpls--post-list li{padding:0;margin:0}#wpls--post-list a{line-height:1;display:block;text-decoration:none;border:none;padding:10px}#wpls--post-list .wpls--item-title{margin:5px auto}.wpls--link{*zoom:1}.wpls--link:before,.wpls--link:after{content:" ";display:table}.wpls--link:after{clear:both}.wpls--link:hover{background:#f4f4f4}.wpls--item-image{float:left;max-width:40px;margin-right:10px}.wpls--item-title{display:inline-block;overflow:hidden;width:auto}#wpls--helper{position:absolute;right:7px;top:7px;font-size:13px;padding:3px 8px;background:#5bc0de;color:white;border-radius:2px;font-family:Arial} diff --git a/public/assets/js/wp-search.js b/public/assets/js/wp-live-search.js similarity index 86% rename from public/assets/js/wp-search.js rename to public/assets/js/wp-live-search.js index 22ce9ac..3432e19 100644 --- a/public/assets/js/wp-search.js +++ b/public/assets/js/wp-live-search.js @@ -2,16 +2,16 @@ jQuery('document').ready( function( $ ){ - var backboneTemplate = $('#wp-search--tmpl') + var backboneTemplate = $('#wpls--tmpl') , itemTemplate = _.template( backboneTemplate.html() ) , posts = new wp.api.collections.Posts() - , postList = '#wp-search--post-list' - , results = '#wp-search--results' - , loader = '#wp-search--loading' - , input = '#wp-search--input' - , helper = '#wp-search--helper' + , postList = '#wpls--post-list' + , results = '#wpls--results' + , loader = '#wpls--loading' + , input = '#wpls--input' + , helper = '#wpls--helper' , helperText = wp_search_vars.helperText - , helperSpan = ''+helperText+'' + , helperSpan = ''+helperText+'' , api = WP_API_Settings.root , timer diff --git a/public/assets/sass/source/_base.scss b/public/assets/sass/source/_base.scss index ee00b08..01d6480 100644 --- a/public/assets/sass/source/_base.scss +++ b/public/assets/sass/source/_base.scss @@ -1,20 +1,20 @@ // Results wrap -.wp-search--results-wrap { +.wpls--results-wrap { opacity:0; } // Input Wrap -#wp-search--input-wrap { +#wpls--input-wrap { position:relative; } // The Input -#wp-search--input { +#wpls--input { height:$input--height; } // List of posts -#wp-search--post-list { +#wpls--post-list { list-style:none; margin:0; padding:0; @@ -33,13 +33,13 @@ padding:$spacing--sm; } - .wp-search--item-title { + .wpls--item-title { margin:5px auto; } } // Item Link -.wp-search--link { +.wpls--link { @include clearfix(); &:hover { @@ -48,21 +48,21 @@ } // Item image -.wp-search--item-image { +.wpls--item-image { float:left; max-width:$spacing--lg; margin-right:$spacing--sm; } // Item title -.wp-search--item-title { +.wpls--item-title { display:inline-block; overflow:hidden; width:auto; } // Character helper -#wp-search--helper { +#wpls--helper { position:absolute; right:7px; top:7px; diff --git a/public/assets/sass/source/_loader.scss b/public/assets/sass/source/_loader.scss index 95dfb56..740f27d 100644 --- a/public/assets/sass/source/_loader.scss +++ b/public/assets/sass/source/_loader.scss @@ -1,5 +1,5 @@ -.wp-search--loading { +.wpls--loading { height:20px; width:20px; position:absolute; @@ -9,7 +9,7 @@ } -.wp-search--loader { +.wpls--loader { height:20px; width:20px; margin:10px auto; diff --git a/public/class-wp-search.php b/public/class-wp-live-search.php similarity index 84% rename from public/class-wp-search.php rename to public/class-wp-live-search.php index 537ce26..a221177 100755 --- a/public/class-wp-search.php +++ b/public/class-wp-live-search.php @@ -2,7 +2,7 @@ /** * WP Search * - * @package WP_Search + * @package WP_Live_Search * @author Nick Haskins * @license GPL-2.0+ * @link http://example.com @@ -11,33 +11,10 @@ /** * - * @package WP_Search + * @package WP_Live_Search * @author Nick Haskins */ -class WP_Search { - - /** - * Plugin version, used for cache-busting of style and script file references. - * - * @since 0.0.1 - * - * @var string - */ - const VERSION = '0.0.1'; - - /** - * Unique identifier - * - * - * The variable name is used as the text domain when internationalizing strings - * of text. Its value should match the Text Domain file header in the main - * plugin file. - * - * @since 0.0.1 - * - * @var string - */ - protected $plugin_slug = 'wp-search'; +class WP_Live_Search { /** * Instance of this class. @@ -64,16 +41,6 @@ private function __construct() { require WP_SEARCH_DIR.'/public/includes/class.assets.php'; } - /** - * Return the plugin slug. - * - * @since 0.0.1 - * - * @return Plugin slug variable. - */ - public function get_plugin_slug() { - return $this->plugin_slug; - } /** * Return an instance of this class. @@ -227,9 +194,4 @@ private static function single_deactivate() { // @TODO: Define deactivation functionality here } -} - - - - - +} \ No newline at end of file diff --git a/public/includes/class.assets.php b/public/includes/class.assets.php index 8ed68ae..3b2d4e0 100644 --- a/public/includes/class.assets.php +++ b/public/includes/class.assets.php @@ -19,11 +19,11 @@ public function scripts(){ wp_localize_script( 'wp-api-js', 'WP_API_Settings', $settings ); // wp search script - wp_enqueue_script('wp-search', WP_SEARCH_URL.'/public/assets/js/wp-search.js', array('jquery'), WP_SEARCH_VERSION, true); - wp_localize_script('wp-search','wp_search_vars', array('helperText' => __('one more character','wp-search'))); + wp_enqueue_script('wpls-script', WP_SEARCH_URL.'/public/assets/js/wp-live-search.js', array('jquery'), WP_SEARCH_VERSION, true); + wp_localize_script('wpls-script','wp_search_vars', array('helperText' => __('one more character','wp-live-search'))); // wp seatch style - wp_enqueue_style('wp-search-style', WP_SEARCH_URL.'/public/assets/css/style.css', WP_SEARCH_VERSION ); + wp_enqueue_style('wpls-style', WP_SEARCH_URL.'/public/assets/css/style.css', WP_SEARCH_VERSION ); } } diff --git a/public/includes/class.shortcode.php b/public/includes/class.shortcode.php index d41b953..d9ee2fa 100644 --- a/public/includes/class.shortcode.php +++ b/public/includes/class.shortcode.php @@ -4,14 +4,15 @@ class wpSearchShortcode{ public function __construct(){ - add_shortcode('wp_search', array($this,'shortcode')); + add_shortcode('wp_live_search', array($this,'shortcode')); } public function shortcode( $atts, $content = null ) { $defaults = array( - 'type' => 'posts', - 'results' => __('entries found','wp-search') + 'type' => 'posts', + 'placeholder' => __('Search...','wp-live-search'), + 'results' => __('entries found','wp-live-search') ); $atts = shortcode_atts( $defaults, $atts ); @@ -20,19 +21,19 @@ public function shortcode( $atts, $content = null ) { ob_start(); ?> -