[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> ms-deprecated.php (source)

   1  <?php
   2  /**
   3   * Deprecated functions from WordPress MU and the multisite feature. You shouldn't
   4   * use these functions and look for the alternatives instead. The functions will be
   5   * removed in a later version.
   6   *
   7   * @package WordPress
   8   * @subpackage Deprecated
   9   * @since 3.0.0
  10   */
  11  
  12  /*
  13   * Deprecated functions come here to die.
  14   */
  15  
  16  /**
  17   * @since MU
  18   * @deprecated 3.0.0
  19   * @deprecated Use wp_generate_password()
  20   * @see wp_generate_password()
  21   */
  22  function generate_random_password( $len = 8 ) {
  23      _deprecated_function( __FUNCTION__, '3.0', 'wp_generate_password()' );
  24      return wp_generate_password( $len );
  25  }
  26  
  27  /**
  28   * Determine if user is a site admin.
  29   *
  30   * Plugins should use is_multisite() instead of checking if this function exists
  31   * to determine if multisite is enabled.
  32   *
  33   * This function must reside in a file included only if is_multisite() due to
  34   * legacy function_exists() checks to determine if multisite is enabled.
  35   *
  36   * @since MU
  37   * @deprecated 3.0.0
  38   * @deprecated Use is_super_admin()
  39   * @see is_super_admin()
  40   * @see is_multisite()
  41   *
  42   */
  43  function is_site_admin( $user_login = '' ) {
  44      _deprecated_function( __FUNCTION__, '3.0', 'is_super_admin()' );
  45  
  46      if ( empty( $user_login ) ) {
  47          $user_id = get_current_user_id();
  48          if ( !$user_id )
  49              return false;
  50      } else {
  51          $user = get_user_by( 'login', $user_login );
  52          if ( ! $user->exists() )
  53              return false;
  54          $user_id = $user->ID;
  55      }
  56  
  57      return is_super_admin( $user_id );
  58  }
  59  
  60  if ( !function_exists( 'graceful_fail' ) ) :
  61  /**
  62   * @since MU
  63   * @deprecated 3.0.0
  64   * @deprecated Use wp_die()
  65   * @see wp_die()
  66   */
  67  function graceful_fail( $message ) {
  68      _deprecated_function( __FUNCTION__, '3.0', 'wp_die()' );
  69      $message = apply_filters( 'graceful_fail', $message );
  70      $message_template = apply_filters( 'graceful_fail_template',
  71  '<!DOCTYPE html>
  72  <html xmlns="http://www.w3.org/1999/xhtml"><head profile="http://gmpg.org/xfn/11">
  73  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  74  <title>Error!</title>
  75  <style type="text/css">
  76  img {
  77      border: 0;
  78  }
  79  body {
  80  line-height: 1.6em; font-family: Georgia, serif; width: 390px; margin: auto;
  81  text-align: center;
  82  }
  83  .message {
  84      font-size: 22px;
  85      width: 350px;
  86      margin: auto;
  87  }
  88  </style>
  89  </head>
  90  <body>
  91  <p class="message">%s</p>
  92  </body>
  93  </html>' );
  94      die( sprintf( $message_template, $message ) );
  95  }
  96  endif;
  97  
  98  /**
  99   * @since MU
 100   * @deprecated 3.0.0
 101   * @deprecated Use get_user_by()
 102   * @see get_user_by()
 103   */
 104  function get_user_details( $username ) {
 105      _deprecated_function( __FUNCTION__, '3.0', 'get_user_by()' );
 106      return get_user_by('login', $username);
 107  }
 108  
 109  /**
 110   * @since MU
 111   * @deprecated 3.0.0
 112   * @deprecated Use clean_post_cache()
 113   * @see clean_post_cache()
 114   */
 115  function clear_global_post_cache( $post_id ) {
 116      _deprecated_function( __FUNCTION__, '3.0', 'clean_post_cache()' );
 117  }
 118  
 119  /**
 120   * @since MU
 121   * @deprecated 3.0.0
 122   * @deprecated Use is_main_site()
 123   * @see is_main_site()
 124   */
 125  function is_main_blog() {
 126      _deprecated_function( __FUNCTION__, '3.0', 'is_main_site()' );
 127      return is_main_site();
 128  }
 129  
 130  /**
 131   * @since MU
 132   * @deprecated 3.0.0
 133   * @deprecated Use is_email()
 134   * @see is_email()
 135   */
 136  function validate_email( $email, $check_domain = true) {
 137      _deprecated_function( __FUNCTION__, '3.0', 'is_email()' );
 138      return is_email( $email, $check_domain );
 139  }
 140  
 141  /**
 142   * @since MU
 143   * @deprecated 3.0.0
 144   * @deprecated No alternative available. For performance reasons this function is not recommended.
 145   */
 146  function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) {
 147      _deprecated_function( __FUNCTION__, '3.0' );
 148  
 149      global $wpdb;
 150      $blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A );
 151  
 152      foreach ( (array) $blogs as $details ) {
 153          $blog_list[ $details['blog_id'] ] = $details;
 154          $blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM " . $wpdb->get_blog_prefix( $details['blog_id'] ). "posts WHERE post_status='publish' AND post_type='post'" );
 155      }
 156      unset( $blogs );
 157      $blogs = $blog_list;
 158  
 159      if ( false == is_array( $blogs ) )
 160          return array();
 161  
 162      if ( $num == 'all' )
 163          return array_slice( $blogs, $start, count( $blogs ) );
 164      else
 165          return array_slice( $blogs, $start, $num );
 166  }
 167  
 168  /**
 169   * @since MU
 170   * @deprecated 3.0.0
 171   * @deprecated No alternative available. For performance reasons this function is not recommended.
 172   */
 173  function get_most_active_blogs( $num = 10, $display = true ) {
 174      _deprecated_function( __FUNCTION__, '3.0' );
 175  
 176      $blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details
 177      if ( is_array( $blogs ) ) {
 178          reset( $blogs );
 179          foreach ( (array) $blogs as $key => $details ) {
 180              $most_active[ $details['blog_id'] ] = $details['postcount'];
 181              $blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!!
 182          }
 183          arsort( $most_active );
 184          reset( $most_active );
 185          foreach ( (array) $most_active as $key => $details )
 186              $t[ $key ] = $blog_list[ $key ];
 187  
 188          unset( $most_active );
 189          $most_active = $t;
 190      }
 191  
 192      if ( $display == true ) {
 193          if ( is_array( $most_active ) ) {
 194              reset( $most_active );
 195              foreach ( (array) $most_active as $key => $details ) {
 196                  $url = esc_url('http://' . $details['domain'] . $details['path']);
 197                  echo '<li>' . $details['postcount'] . " <a href='$url'>$url</a></li>";
 198              }
 199          }
 200      }
 201      return array_slice( $most_active, 0, $num );
 202  }
 203  
 204  /**
 205   * Redirect a user based on $_GET or $_POST arguments.
 206   *
 207   * The function looks for redirect arguments in the following order:
 208   * 1) $_GET['ref']
 209   * 2) $_POST['ref']
 210   * 3) $_SERVER['HTTP_REFERER']
 211   * 4) $_GET['redirect']
 212   * 5) $_POST['redirect']
 213   * 6) $url
 214   *
 215   * @since MU
 216   * @deprecated 3.3.0
 217   * @deprecated Use wp_redirect()
 218   * @uses wpmu_admin_redirect_add_updated_param()
 219   *
 220   * @param string $url
 221   */
 222  function wpmu_admin_do_redirect( $url = '' ) {
 223      _deprecated_function( __FUNCTION__, '3.3' );
 224  
 225      $ref = '';
 226      if ( isset( $_GET['ref'] ) )
 227          $ref = $_GET['ref'];
 228      if ( isset( $_POST['ref'] ) )
 229          $ref = $_POST['ref'];
 230  
 231      if ( $ref ) {
 232          $ref = wpmu_admin_redirect_add_updated_param( $ref );
 233          wp_redirect( $ref );
 234          exit();
 235      }
 236      if ( empty( $_SERVER['HTTP_REFERER'] ) == false ) {
 237          wp_redirect( $_SERVER['HTTP_REFERER'] );
 238          exit();
 239      }
 240  
 241      $url = wpmu_admin_redirect_add_updated_param( $url );
 242      if ( isset( $_GET['redirect'] ) ) {
 243          if ( substr( $_GET['redirect'], 0, 2 ) == 's_' )
 244              $url .= '&action=blogs&s='. esc_html( substr( $_GET['redirect'], 2 ) );
 245      } elseif ( isset( $_POST['redirect'] ) ) {
 246          $url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
 247      }
 248      wp_redirect( $url );
 249      exit();
 250  }
 251  
 252  /**
 253   * Adds an 'updated=true' argument to a URL.
 254   *
 255   * @since MU
 256   * @deprecated 3.3.0
 257   * @deprecated Use add_query_arg()
 258   *
 259   * @param string $url
 260   * @return string
 261   */
 262  function wpmu_admin_redirect_add_updated_param( $url = '' ) {
 263      _deprecated_function( __FUNCTION__, '3.3' );
 264  
 265      if ( strpos( $url, 'updated=true' ) === false ) {
 266          if ( strpos( $url, '?' ) === false )
 267              return $url . '?updated=true';
 268          else
 269              return $url . '&updated=true';
 270      }
 271      return $url;
 272  }


Generated: Fri May 25 03:56:23 2012 Hosted by follow the white rabbit.