Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate hooks and functions with improper names #269

Merged
merged 21 commits into from Apr 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/connector.php
Expand Up @@ -56,7 +56,7 @@ public static function callback() {
*
* @param array $callback Callback name
*/
do_action( 'stream_test_' . $callback[1] );
do_action( 'wp_stream_test_' . $callback[1] );
}

// Call the real function
Expand Down
4 changes: 2 additions & 2 deletions connectors/editor.php
Expand Up @@ -93,8 +93,8 @@ public static function get_message() {
*/
public static function action_links( $links, $record ) {
if ( current_user_can( 'edit_theme_options' ) ) {
$file_name = get_stream_meta( $record->ID, 'file', true );
$theme_slug = get_stream_meta( $record->ID, 'theme_slug', true );
$file_name = wp_stream_get_meta( $record->ID, 'file', true );
$theme_slug = wp_stream_get_meta( $record->ID, 'theme_slug', true );

if ( '' !== $file_name && '' !== $theme_slug ) {
$links[ __( 'Edit File', 'stream' ) ] = admin_url(
Expand Down
2 changes: 1 addition & 1 deletion connectors/installer.php
Expand Up @@ -75,7 +75,7 @@ public static function get_context_labels() {
public static function action_links( $links, $record ) {
if ( 'wordpress' === $record->context && 'updated' === $record->action ) {
global $wp_version;
$version = get_stream_meta( $record->ID, 'new_version', true );
$version = wp_stream_get_meta( $record->ID, 'new_version', true );
if ( $version === $wp_version ) {
$links[ __( 'About', 'stream' ) ] = admin_url( 'about.php?updated' );
}
Expand Down
2 changes: 1 addition & 1 deletion connectors/posts.php
Expand Up @@ -72,7 +72,7 @@ public static function action_links( $links, $record ) {
$links[ __( 'View', 'stream' ) ] = $link;
}
if ( 'updated' == $record->action ) {
if ( $revision_id = get_stream_meta( $record->ID, 'revision_id', true ) ) {
if ( $revision_id = wp_stream_get_meta( $record->ID, 'revision_id', true ) ) {
$links[ __( 'Revision', 'stream' ) ] = get_edit_post_link( $revision_id );
}
}
Expand Down
6 changes: 3 additions & 3 deletions connectors/settings.php
Expand Up @@ -291,7 +291,7 @@ public static function action_links( $links, $record ) {
'menu_slug' => 'wp_stream',
'submenu_slug' => WP_Stream_Admin::SETTINGS_PAGE_SLUG,
'url' => function( $rule, $record ) {
$option_key = get_stream_meta( $record->ID, 'option_key', true );
$option_key = wp_stream_get_meta( $record->ID, 'option_key', true );
$url_tab = null;

if ( '' !== $option_key ) {
Expand Down Expand Up @@ -375,10 +375,10 @@ function( $rule ) use ( $submenu, $record ) {
if ( current_user_can( $capability ) ) {
$url = apply_filters( 'wp_stream_action_link_url', $url, $record );
$text = sprintf( __( 'Edit %s Settings', 'stream' ), $context_labels[ $record->context ] );
$field_name = get_stream_meta( $record->ID, 'option_key', true );
$field_name = wp_stream_get_meta( $record->ID, 'option_key', true );

if ( '' === $field_name ) {
$field_name = get_stream_meta( $record->ID, 'option', true );
$field_name = wp_stream_get_meta( $record->ID, 'option', true );
}

if ( '' !== $field_name ) {
Expand Down
2 changes: 1 addition & 1 deletion connectors/widgets.php
Expand Up @@ -73,7 +73,7 @@ public static function get_context_labels() {
* @return array Action links
*/
public static function action_links( $links, $record ) {
if ( $sidebar = get_stream_meta( $record->ID, 'sidebar', true ) ) {
if ( $sidebar = wp_stream_get_meta( $record->ID, 'sidebar', true ) ) {
global $wp_registered_sidebars;

if ( array_key_exists( $sidebar, $wp_registered_sidebars ) ) {
Expand Down
4 changes: 2 additions & 2 deletions includes/admin.php
Expand Up @@ -566,7 +566,7 @@ public static function dashboard_stream_activity_contents( $paged = 1 ) {
'paged' => $paged,
);

$records = stream_query( $args );
$records = wp_stream_query( $args );

if ( ! $records ) {
?>
Expand Down Expand Up @@ -875,7 +875,7 @@ public static function gather_updated_items( $last_id, $query = array() ) {
$query = wp_parse_args( $query, $default );

// Run query
$items = stream_query( $query );
$items = wp_stream_query( $query );

return $items;
}
Expand Down
2 changes: 1 addition & 1 deletion includes/date-interval.php
Expand Up @@ -117,7 +117,7 @@ public function get_predefined_intervals() {
* @return array
*/
public function filter_predefined_intervals( $intervals ) {
$query = stream_query(
$query = wp_stream_query(
array(
'order' => 'ASC',
'orderby' => 'created',
Expand Down
113 changes: 113 additions & 0 deletions includes/deprecated.php
@@ -0,0 +1,113 @@
<?php

/**
* Handle deprecated filters
*/

global $wp_stream_deprecated_filters;

$wp_stream_deprecated_filters = array(
array(
'old' => 'stream_query_args',
'new' => 'wp_stream_query_args',
'version' => '1.3.2',
),
array(
'old' => 'stream_toggle_filters',
'new' => 'wp_stream_toggle_filters',
'version' => '1.3.2',
),
);

foreach ( $wp_stream_deprecated_filters as $filter ) {
add_filter( $filter['new'], 'wp_stream_deprecated_filter_mapping' );
}

function wp_stream_deprecated_filter_mapping( $data ) {
global $wp_stream_deprecated_filters;

$new_filter = current_filter();
$old_filter = false;
$version = false;

foreach ( $wp_stream_deprecated_filters as $key => $filter ) {
if ( $new_filter === $filter['new'] ) {
$old_filter = $filter['old'];
$version = $filter['version'];
break;
}
}

if ( ! $old_filter || ! has_filter( $old_filter ) ) {
return $data;
}

$filter_args = array_merge(
array(
$old_filter,
),
func_get_args()
);

$data = call_user_func_array( 'apply_filters', $filter_args );

_deprecated_function(
sprintf( __( 'The %s filter', 'stream' ), $old_filter ),
$version,
$new_filter
);

return $data;
}

/**
* stream_query()
*
* @deprecated 1.3.2
* @deprecated Use wp_stream_query()
* @see wp_stream_query()
*/
function stream_query( $args = array() ) {
_deprecated_function( __FUNCTION__, '1.3.2', 'wp_stream_query()' );

return wp_stream_query( $args );
}

/**
* get_stream_meta()
*
* @deprecated 1.3.2
* @deprecated Use wp_stream_get_meta
* @see wp_stream_get_meta()
*/
function get_stream_meta( $record_id, $key = '', $single = false ) {
_deprecated_function( __FUNCTION__, '1.3.2', 'wp_stream_get_meta()' );

return wp_stream_get_meta( $record_id, $key, $single );
}

/**
* update_stream_meta()
*
* @deprecated 1.3.2
* @deprecated Use wp_stream_update_meta
* @see wp_stream_update_meta()
*/
function update_stream_meta( $record_id, $meta_key, $meta_value, $prev_value = '' ) {
_deprecated_function( __FUNCTION__, '1.3.2', 'wp_stream_update_meta()' );

return wp_stream_update_meta( $record_id, $meta_key, $meta_value, $prev_value );
}

/**
* existing_records()
*
* @deprecated 1.3.2
* @deprecated Use wp_stream_existing_records
* @see wp_stream_existing_records()
*/
function existing_records( $column, $table = '' ) {
_deprecated_function( __FUNCTION__, '1.3.2', 'wp_stream_existing_records()' );

return wp_stream_existing_records( $column, $table );
}
2 changes: 1 addition & 1 deletion includes/feeds.php
Expand Up @@ -145,7 +145,7 @@ public static function feed_template() {
'fields' => wp_stream_filter_input( INPUT_GET, 'fields', FILTER_DEFAULT, array( 'options' => array( 'default' => 'with-meta' ) ) ),
);

$records = stream_query( $args );
$records = wp_stream_query( $args );

$latest_record = isset( $records[0]->created ) ? $records[0]->created : null;

Expand Down
12 changes: 6 additions & 6 deletions includes/install.php
Expand Up @@ -184,7 +184,7 @@ public static function update( $db_version, $current ) {
foreach ( $media_records as $record ) {
$post = get_post( $record->pid );
$guid = isset( $post->guid ) ? $post->guid : null;
$url = $guid ? $guid : get_stream_meta( $record->id, 'url', true );
$url = $guid ? $guid : wp_stream_get_meta( $record->id, 'url', true );

if ( ! empty( $url ) ) {
$wpdb->update(
Expand Down Expand Up @@ -255,11 +255,11 @@ public static function migrate_installer_edits_to_theme_editor_connector() {
'context' => 'themes',
'action' => 'edited',
);
$records = stream_query( $args );
$records = wp_stream_query( $args );

foreach ( $records as $record ) {
$file_name = get_stream_meta( $record->ID, 'file', true );
$theme_name = get_stream_meta( $record->ID, 'name', true );
$file_name = wp_stream_get_meta( $record->ID, 'file', true );
$theme_name = wp_stream_get_meta( $record->ID, 'name', true );

if ( '' !== $theme_name ) {
$matched_themes = array_filter(
Expand Down Expand Up @@ -290,10 +290,10 @@ function( $theme ) use ( $theme_name ) {
array( 'record_id' => $record->ID )
);

update_stream_meta( $record->ID, 'theme_name', $theme_name );
wp_update_stream_meta( $record->ID, 'theme_name', $theme_name );

if ( is_object( $theme ) ) {
update_stream_meta( $record->ID, 'theme_slug', $theme->get_template() );
wp_update_stream_meta( $record->ID, 'theme_slug', $theme->get_template() );
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions includes/list-table.php
Expand Up @@ -173,7 +173,7 @@ function get_records() {
$args['records_per_page'] = $this->get_items_per_page( 'edit_stream_per_page', 20 );
}

$items = stream_query( $args );
$items = wp_stream_query( $args );

return $items;
}
Expand Down Expand Up @@ -387,7 +387,7 @@ public function get_term_title( $term, $type ) {
* results of existing records. All items that do not exist in records
* get assigned a disabled value of "true".
*
* @uses existing_records (see query.php)
* @uses wp_stream_existing_records (see query.php)
* @since 1.0.4
*
* @param string Column requested
Expand Down Expand Up @@ -436,7 +436,7 @@ function assemble_records( $column, $table = '' ) {
}
}

$existing_records = existing_records( $column, $table );
$existing_records = wp_stream_existing_records( $column, $table );
$active_records = array();
$disabled_records = array();

Expand Down Expand Up @@ -745,7 +745,7 @@ static function screen_controls( $status, $args ) {
<div class="metabox-prefs stream-toggle-filters">
<?php
$filters = apply_filters(
'stream_toggle_filters', array(
'wp_stream_toggle_filters', array(
'date_range' => __( 'Date Range', 'stream' ),
'author' => __( 'Authors', 'stream' ),
'connector' => __( 'Connectors', 'stream' ),
Expand Down
10 changes: 5 additions & 5 deletions includes/query.php
Expand Up @@ -70,7 +70,7 @@ public function query( $args ) {
* @param array Array of query arguments
* @return array Updated array of query arguments
*/
$args = apply_filters( 'stream_query_args', $args );
$args = apply_filters( 'wp_stream_query_args', $args );

if ( true === $args[ 'hide_excluded' ] ) {
$args = self::add_excluded_record_args( $args );
Expand Down Expand Up @@ -343,15 +343,15 @@ public static function add_excluded_record_args( $args ) {

}

function stream_query( $args = array() ) {
function wp_stream_query( $args = array() ) {
return WP_Stream_Query::get_instance()->query( $args );
}

function get_stream_meta( $record_id, $key = '', $single = false ) {
function wp_stream_get_meta( $record_id, $key = '', $single = false ) {
return get_metadata( 'record', $record_id, $key, $single );
}

function update_stream_meta( $record_id, $meta_key, $meta_value, $prev_value = '' ) {
function wp_stream_update_meta( $record_id, $meta_key, $meta_value, $prev_value = '' ) {
return update_metadata( 'record', $record_id, $meta_key, $meta_value, $prev_value );
}

Expand All @@ -370,7 +370,7 @@ function update_stream_meta( $record_id, $meta_key, $meta_value, $prev_value = '
* @param string Requested Table
* @return array Array of items to be output to select dropdowns
*/
function existing_records( $column, $table = '' ) {
function wp_stream_existing_records( $column, $table = '' ) {
global $wpdb;

switch ( $table ) {
Expand Down
3 changes: 3 additions & 0 deletions stream.php
Expand Up @@ -115,6 +115,9 @@ private function __construct() {
require_once WP_STREAM_INC_DIR . 'admin.php';
add_action( 'plugins_loaded', array( 'WP_Stream_Admin', 'load' ) );
}

// Load deprecated functions
require_once WP_STREAM_INC_DIR . 'deprecated.php';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/testcase.php
Expand Up @@ -18,7 +18,7 @@ class WP_StreamTestCase extends WP_UnitTestCase {
* Custom action prefix for test custom triggered actions
* @var string
*/
protected $action_prefix = 'stream_test_';
protected $action_prefix = 'wp_stream_test_';

/**
* PHP unit setup function
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/test-post-connector.php
Expand Up @@ -27,7 +27,7 @@ public function test_transition_post_status() {
$this->assertGreaterThan( 0, did_action( $this->action_prefix . 'callback_transition_post_status' ) );

//Check if the entry is in the database
$result = stream_query(
$result = wp_stream_query(
array(
'object_id' => $post_id,
'context' => 'post',
Expand Down Expand Up @@ -57,7 +57,7 @@ public function test_delete_post_log() {
$this->assertGreaterThan( 0, did_action( $this->action_prefix . 'callback_deleted_post' ) );

//Check if the entry is in the database
$result = stream_query(
$result = wp_stream_query(
array(
'object_id' => $post_id,
'context' => 'post',
Expand Down