Changeset 1222872
- Timestamp:
- 08/17/2015 04:59:12 PM (11 years ago)
- Location:
- server-side-google-search/trunk
- Files:
-
- 5 added
- 5 edited
-
bin (added)
-
bin/install-wp-tests.sh (added)
-
phpunit.xml (added)
-
readme.txt (modified) (3 diffs)
-
ssgs-google-search.php (modified) (2 diffs)
-
ssgs-widget.php (modified) (8 diffs)
-
tests/SSGSWidgetTestBase.php (modified) (1 diff)
-
tests/bootstrap.php (added)
-
tests/mock-option.php (modified) (2 diffs)
-
tests/test-widget.php (added)
Legend:
- Unmodified
- Added
- Removed
-
server-side-google-search/trunk/readme.txt
r1172931 r1222872 3 3 Tags: Server-Side Google Search, Google Search, Google Custom Search, Google, SCE, GCSE, Wordpress Google Search 4 4 Requires at least: 3.7 5 Tested up to: 4. 06 Stable tag: 1.0. 25 Tested up to: 4.3 6 Stable tag: 1.0.3 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 72 72 == Changelog == 73 73 74 = 1.0.3 = 75 * Removed deprecation warnings for WordPress 4.3 76 * Fixed potential bug where sort argument wasn't being preserved in links 77 * Updated test infrastructure to use wp-cli 78 * Documentation updates 79 74 80 = 1.0.2 = 75 81 * Added filter to allow custom metadata in search results … … 86 92 = 1.0.0 = 87 93 * First version 94 95 96 == Development == 97 98 This plugin uses [wp-cli](http://wp-cli.org/) and [PHPUnit](https://phpunit.de/) for testing. 99 The tests require [runkit](https://github.com/zenovich/runkit) for mocking functions. 100 101 * Grab the latest source from github: 102 103 ` 104 $ git clone git@github.com:aptivate/server-side-google-search.git 105 ` 106 107 * Install [wp-cli](http://wp-cli.org/#install) 108 * Install [PHPUnit](https://phpunit.de/) 109 * Set up runkit: 110 111 ` 112 $ git clone https://github.com/zenovich/runkit.git 113 $ cd runkit 114 $ phpize 115 $ ./configure 116 $ sudo make install 117 ` 118 119 Add the following lines to `/etc/php5/cli/php.ini`: 120 121 ` 122 extension=runkit.so 123 runkit.internal_override=1 124 ` 125 126 * Install the test WordPress environment: 127 128 ` 129 cd server-side-google-search 130 bash bin/install-wp-tests.sh test_db_name db_user 'db_password' db_host version 131 ` 132 133 where: 134 ** `test_db_name` is the name for your **temporary** test WordPress database 135 ** `db_user` is the database user name 136 ** `db_password` is the password 137 ** `db_host` is the database host (eg `localhost`) 138 ** `version` is the version of WordPress (eg `4.2.2` or `latest`) 139 140 * Run the tests 141 `phpunit` -
server-side-google-search/trunk/ssgs-google-search.php
r1172931 r1222872 4 4 Plugin URI: https://github.com/aptivate/server-side-google-search 5 5 Description: Google Custom Search for your site, without JavaScript 6 Version: 1.0. 26 Version: 1.0.3 7 7 Author: Aptivate 8 8 Author URI: http://www.aptivate.org/ … … 11 11 Domain Path: /languages/ 12 12 Requires at least: 3.7 13 Tested up to: 4. 013 Tested up to: 4.3 14 14 */ 15 15 -
server-side-google-search/trunk/ssgs-widget.php
r1172931 r1222872 5 5 6 6 public function __construct() { 7 parent:: WP_Widget( false, $name =__( 'Server-Side Google Search (SSGS)','ssgs' ) );7 parent::__construct( false, __( 'Server-Side Google Search (SSGS)','ssgs' ) ); 8 8 } 9 9 … … 11 11 $this->options = get_option( 'ssgs_general_settings' ); 12 12 $this->sanitize_parameters(); 13 14 global $ssgs;15 13 16 14 echo $args['before_widget']; … … 80 78 $this->parameters['s'] = trim( $this->parameters['s'] ); 81 79 } 82 83 $this->extra_parameters = array_diff_assoc( $this->parameters, $defaults );84 80 } 85 81 … … 102 98 if ( ! preg_match( '/^[a-z_]+$/', 103 99 $this->parameters[ $name ] ) ) { 104 $this->parameters[ $name ] = false;100 $this->parameters[ $name ] = ''; 105 101 } 106 102 } … … 121 117 $total_items = $this->get_total_items( $result ); 122 118 if ( $total_items <= 0 ) { 123 $content = '<p><strong>' . __( 'Sorry, there were no results', 'ssgs' ) ."</strong></p>\n"; 124 }else { 125 $content = $this->get_results_content( $result ); 126 127 } // End else -- $total_items <= 0 128 129 return $content; 119 return '<p><strong>' . __( 'Sorry, there were no results', 'ssgs' ) ."</strong></p>\n"; 120 } 121 122 return $this->get_results_content( $result ); 130 123 } 131 124 … … 146 139 147 140 private function get_other_pages_content( $result ) { 141 $content = ''; 142 148 143 $page_length = $this->get_page_length(); 149 144 $start = $this->get_page_start(); … … 259 254 260 255 private function get_result_list( $items ) { 261 $content .= '<ul class="ssgs-result-list">';256 $content = '<ul class="ssgs-result-list">'; 262 257 263 258 foreach ( $items as $item ) { … … 429 424 430 425 $parsed_url = parse_url( home_url( add_query_arg( array(), $wp->request ) ) ); 431 $query_args = array_merge( $this->extra_parameters, $query_args ); 426 427 $query_args = array_merge( $this->parameters, $query_args ); 432 428 433 429 return htmlentities( $this->build_url( $parsed_url, $query_args ) ); -
server-side-google-search/trunk/tests/SSGSWidgetTestBase.php
r1172931 r1222872 1 1 <?php 2 class SSGSWidgetTestBase extends PHPUnit_Framework_TestCase2 abstract class SSGSWidgetTestBase extends WP_UnitTestCase 3 3 { 4 4 protected function get_html_element_from_output( $output, $path ) -
server-side-google-search/trunk/tests/mock-option.php
r1172931 r1222872 13 13 'edition' => '', 14 14 'default_search_image_url' => '', 15 'show_urls' => 'yes', 15 16 ); 16 17 … … 25 26 26 27 default: 27 throw new Exception( "Unexpected option: '$option'" );28 return "Mock option: $option"; 28 29 } 29 30 }
Note: See TracChangeset
for help on using the changeset viewer.