[ Index ]

PHP Cross Reference of BBPress

title

Body

[close]

/src/includes/admin/tools/ -> common.php (source)

   1  <?php
   2  
   3  /**
   4   * bbPress Admin Tools Common
   5   *
   6   * @package bbPress
   7   * @subpackage Administration
   8   */
   9  
  10  // Exit if accessed directly
  11  defined( 'ABSPATH' ) || exit;
  12  
  13  /**
  14   * Return the current admin repair tool page
  15   *
  16   * @since 2.6.0 (r6894)
  17   *
  18   * @return string
  19   */
  20  function bbp_get_admin_repair_tool_page() {
  21      return sanitize_key( $_GET['page'] );
  22  }
  23  
  24  /**
  25   * Return the current admin repair tool page ID
  26   *
  27   * @since 2.6.0 (r6894)
  28   *
  29   * @return string
  30   */
  31  function bbp_get_admin_repair_tool_page_id() {
  32  
  33      // Get the page
  34      $page = bbp_get_admin_repair_tool_page();
  35  
  36      // Maybe trim prefix off of page
  37      if ( ! empty( $page ) && ( 0 === strpos( $page, 'bbp-' ) ) ) {
  38          $page = str_replace( 'bbp-', '', $page );
  39      } else {
  40          $page = '';
  41      }
  42  
  43      return $page;
  44  }
  45  
  46  /**
  47   * Return a URL to the repair tool page
  48   *
  49   * @since 2.6.0 (r6894)
  50   *
  51   * @param array $args
  52   *
  53   * @return string
  54   */
  55  function bbp_get_admin_repair_tool_page_url( $args = array() ) {
  56  
  57      // Parse arguments
  58      $r = wp_parse_args( $args, array(
  59          'page' => bbp_get_admin_repair_tool_page()
  60      ) );
  61  
  62      return add_query_arg( $r, admin_url( 'tools.php' ) );
  63  }
  64  
  65  /**
  66   * Output the URL to run a specific repair tool
  67   *
  68   * @since 2.6.0 bbPress (r5885)
  69   *
  70   * @param string $component
  71   */
  72  function bbp_admin_repair_tool_run_url( $component = array() ) {
  73      echo esc_url( bbp_get_admin_repair_tool_run_url( $component ) );
  74  }
  75  
  76      /**
  77       * Return the URL to run a specific repair tool
  78       *
  79       * @since 2.6.0 bbPress (r5885)
  80       *
  81       * @param string $component
  82       */
  83  	function bbp_get_admin_repair_tool_run_url( $component = array() ) {
  84  
  85          // Page
  86          $page = ( 'repair' === $component['type'] )
  87              ? 'bbp-repair'
  88              : 'bbp-upgrade';
  89  
  90          // Arguments
  91          $args = array(
  92              'page'    => $page,
  93              'action'  => 'run',
  94              'checked' => array( $component['id'] )
  95          );
  96  
  97          // Url
  98          $nonced = wp_nonce_url( bbp_get_admin_repair_tool_page_url( $args ), 'bbpress-do-counts' );
  99  
 100          // Filter & return
 101          return apply_filters( 'bbp_get_admin_repair_tool_run_url', $nonced, $component );
 102      }
 103  
 104  /**
 105   * Assemble the admin notices
 106   *
 107   * @since 2.0.0 bbPress (r2613)
 108   *
 109   * @param string|WP_Error $message        A message to be displayed or {@link WP_Error}
 110   * @param string          $class          Optional. A class to be added to the message div
 111   * @param bool            $is_dismissible Optional. True to dismiss, false to persist
 112   *
 113   * @return string The message HTML
 114   */
 115  function bbp_admin_tools_feedback( $message, $class = false, $is_dismissible = true ) {
 116      return bbp_admin()->add_notice( $message, $class, $is_dismissible );
 117  }
 118  
 119  /**
 120   * Handle the processing and feedback of the admin tools page
 121   *
 122   * @since 2.0.0 bbPress (r2613)
 123   *
 124   */
 125  function bbp_admin_repair_handler() {
 126  
 127      // Bail if not an actionable request
 128      if ( ! bbp_is_get_request() ) {
 129          return;
 130      }
 131  
 132      // Get the current action or bail
 133      if ( ! empty( $_GET['action'] ) ) {
 134          $action = sanitize_key( $_GET['action'] );
 135      } elseif ( ! empty( $_GET['action2'] ) ) {
 136          $action = sanitize_key( $_GET['action2'] );
 137      } else {
 138          return;
 139      }
 140  
 141      // Bail if not running an action
 142      if ( 'run' !== $action ) {
 143          return;
 144      }
 145  
 146      check_admin_referer( 'bbpress-do-counts' );
 147  
 148      // Parse list of checked repairs
 149      $checked = ! empty( $_GET['checked'] )
 150          ? array_map( 'sanitize_key', $_GET['checked'] )
 151          : array();
 152  
 153      // Flush all caches before running tools
 154      wp_cache_flush();
 155  
 156      // Get the list
 157      $list = bbp_get_admin_repair_tools();
 158  
 159      // Stores messages
 160      $messages = array();
 161  
 162      // Run through checked repair tools
 163      if ( count( $checked ) ) {
 164          foreach ( $checked as $item_id ) {
 165              if ( isset( $list[ $item_id ] ) && is_callable( $list[ $item_id ]['callback'] ) ) {
 166                  $messages[] = call_user_func( $list[ $item_id ]['callback'] );
 167              }
 168          }
 169      }
 170  
 171      // Feedback
 172      if ( count( $messages ) ) {
 173          foreach ( $messages as $message ) {
 174              bbp_admin_tools_feedback( $message[1] );
 175          }
 176      }
 177  
 178      // Flush all caches after running tools
 179      wp_cache_flush();
 180  }
 181  
 182  /**
 183   * Get the array of available repair tools
 184   *
 185   * @since 2.6.0 bbPress (r5885)
 186   *
 187   * @param string $type repair|upgrade The type of tools to get. Default empty for all tools.
 188   * @return array
 189   */
 190  function bbp_get_admin_repair_tools( $type = '' ) {
 191  
 192      // Get tools array
 193      $tools = ! empty( bbp_admin()->tools )
 194          ? bbp_admin()->tools
 195          : array();
 196  
 197      // Maybe limit to type (otherwise return all tools)
 198      if ( ! empty( $type ) ) {
 199          $tools = wp_list_filter( bbp_admin()->tools, array( 'type' => $type ) );
 200      }
 201  
 202      // Filter & return
 203      return (array) apply_filters( 'bbp_get_admin_repair_tools', $tools, $type );
 204  }
 205  
 206  /**
 207   * Return array of components from the array of registered tools
 208   *
 209   * @since 2.5.0 bbPress (r5885)
 210   *
 211   * @return array
 212   */
 213  function bbp_get_admin_repair_tool_registered_components() {
 214  
 215      // Default return value
 216      $retval = array();
 217  
 218      // Get tools
 219      $tools  = bbp_get_admin_repair_tools( bbp_get_admin_repair_tool_page_id() );
 220  
 221      // Loop through tools
 222      if ( ! empty( $tools ) ) {
 223          $plucked = wp_list_pluck( $tools, 'components' );
 224  
 225          // Loop through components
 226          if ( count( $plucked ) ) {
 227              foreach ( $plucked as $components ) {
 228                  foreach ( $components as $component ) {
 229  
 230                      // Skip if already in array
 231                      if ( in_array( $component, $retval, true ) ) {
 232                          continue;
 233                      }
 234  
 235                      // Add component to the array
 236                      $retval[] = $component;
 237                  }
 238              }
 239          }
 240      }
 241  
 242      // Filter & return
 243      return (array) apply_filters( 'bbp_get_admin_repair_tool_registered_components', $retval );
 244  }
 245  
 246  /**
 247   * Output the repair list search form
 248   *
 249   * @since 2.6.0 bbPress (r5885)
 250   */
 251  function bbp_admin_repair_list_search_form() {
 252      ?>
 253  
 254      <p class="search-box">
 255          <label class="screen-reader-text" for="bbp-repair-search-input"><?php esc_html_e( 'Search Tools:', 'bbpress' ); ?></label>
 256          <input type="search" id="bbp-repair-search-input" name="s" value="<?php _admin_search_query(); ?>">
 257          <input type="submit" id="search-submit" class="button" value="<?php esc_html_e( 'Search Tools', 'bbpress' ); ?>">
 258      </p>
 259  
 260      <?php
 261  }
 262  
 263  /**
 264   * Output a select drop-down of components to filter by
 265   *
 266   * @since 2.5.0 bbPress (r5885)
 267   */
 268  function bbp_admin_repair_list_components_filter() {
 269  
 270      // Sanitize component value, if exists
 271      $selected = ! empty( $_GET['components'] )
 272          ? sanitize_key( $_GET['components'] )
 273          : '';
 274  
 275      // Get registered components
 276      $components = bbp_get_admin_repair_tool_registered_components();
 277  
 278      // Bail if no components
 279      if ( empty( $components ) ) {
 280          return;
 281      } ?>
 282  
 283      <label class="screen-reader-text" for="components"><?php esc_html_e( 'Filter by Component', 'bbpress' ); ?></label>
 284      <select name="components" id="components" class="postform">
 285          <option value="" <?php selected( $selected, false ); ?>><?php esc_html_e( 'All Components', 'bbpress' ); ?></option>
 286  
 287          <?php foreach ( $components as $component ) : ?>
 288  
 289              <option class="level-0" value="<?php echo esc_attr( $component ); ?>" <?php selected( $selected, $component ); ?>><?php echo esc_html( bbp_admin_repair_tool_translate_component( $component ) ); ?></option>
 290  
 291          <?php endforeach; ?>
 292  
 293      </select>
 294  
 295      <?php
 296  }
 297  
 298  /**
 299   * Return array of versions from the array of registered tools
 300   *
 301   * @since 2.6.0 bbPress (r6894)
 302   *
 303   * @return array
 304   */
 305  function bbp_get_admin_repair_tool_registered_versions() {
 306  
 307      // Default return value
 308      $retval = array();
 309  
 310      // Get tools
 311      $tools  = bbp_get_admin_repair_tools( bbp_get_admin_repair_tool_page_id() );
 312  
 313      // Loop through tools
 314      if ( ! empty( $tools ) ) {
 315          $plucked = wp_list_pluck( $tools, 'version' );
 316  
 317          // Loop through components
 318          if ( count( $plucked ) ) {
 319              foreach ( $plucked as $versions ) {
 320  
 321                  // Skip if empty
 322                  if ( empty( $versions ) ) {
 323                      continue;
 324  
 325                  // Cast to array if string
 326                  } elseif ( is_string( $versions ) ) {
 327                      $versions = (array) $versions;
 328                  }
 329  
 330                  // Loop through versions
 331                  foreach ( $versions as $version ) {
 332  
 333                      // Skip if already in array
 334                      if ( in_array( $version, $retval, true ) ) {
 335                          continue;
 336                      }
 337  
 338                      // Add component to the array
 339                      $retval[] = $version;
 340                  }
 341              }
 342          }
 343      }
 344  
 345      // Filter & return
 346      return (array) apply_filters( 'bbp_get_admin_repair_tool_registered_versions', $retval );
 347  }
 348  
 349  /**
 350   * Output a select drop-down of versions to filter by
 351   *
 352   * @since 2.5.0 bbPress (r6894)
 353   */
 354  function bbp_admin_repair_list_versions_filter() {
 355  
 356      // Sanitize component value, if exists
 357      $selected = ! empty( $_GET['version'] )
 358          ? sanitize_text_field( $_GET['version'] )
 359          : '';
 360  
 361      // Get registered components
 362      $versions = bbp_get_admin_repair_tool_registered_versions();
 363  
 364      // Bail if no components
 365      if ( empty( $versions ) ) {
 366          return;
 367      } ?>
 368  
 369      <label class="screen-reader-text" for="version"><?php esc_html_e( 'Filter by Version', 'bbpress' ); ?></label>
 370      <select name="version" id="version" class="postform">
 371          <option value="" <?php selected( $selected, false ); ?>><?php esc_html_e( 'All Versions', 'bbpress' ); ?></option>
 372  
 373          <?php foreach ( $versions as $version ) : ?>
 374  
 375              <option class="level-0" value="<?php echo esc_attr( $version ); ?>" <?php selected( $selected, $version ); ?>><?php echo esc_html( bbp_admin_repair_tool_translate_version( $version ) ); ?></option>
 376  
 377          <?php endforeach; ?>
 378  
 379      </select>
 380  
 381      <?php
 382  }
 383  
 384  /** Translations **************************************************************/
 385  
 386  /**
 387   * Maybe translate a repair tool overhead name
 388   *
 389   * @since 2.6.0 bbPress (r6177)
 390   *
 391   * @param string $overhead
 392   * @return string
 393   */
 394  function bbp_admin_repair_tool_translate_overhead( $overhead = '' ) {
 395  
 396      // Get the name of the component
 397      switch ( $overhead ) {
 398          case 'low' :
 399              $name = esc_html__( 'Low', 'bbpress' );
 400              break;
 401          case 'medium' :
 402              $name = esc_html__( 'Medium', 'bbpress' );
 403              break;
 404          case 'high' :
 405              $name = esc_html__( 'High', 'bbpress' );
 406              break;
 407          default :
 408              $name = ucwords( $overhead );
 409              break;
 410      }
 411  
 412      return $name;
 413  }
 414  
 415  /**
 416   * Maybe translate a repair tool component name
 417   *
 418   * @since 2.6.0 bbPress (r5885)
 419   *
 420   * @param string $component
 421   * @return string
 422   */
 423  function bbp_admin_repair_tool_translate_component( $component = '' ) {
 424  
 425      // Get the name of the component
 426      switch ( $component ) {
 427          case 'bbp_user' :
 428              $name = esc_html__( 'Users', 'bbpress' );
 429              break;
 430          case bbp_get_forum_post_type() :
 431              $name = esc_html__( 'Forums', 'bbpress' );
 432              break;
 433          case bbp_get_topic_post_type() :
 434              $name = esc_html__( 'Topics', 'bbpress' );
 435              break;
 436          case bbp_get_reply_post_type() :
 437              $name = esc_html__( 'Replies', 'bbpress' );
 438              break;
 439          case bbp_get_topic_tag_tax_id() :
 440              $name = esc_html__( 'Topic Tags', 'bbpress' );
 441              break;
 442          case bbp_get_user_rewrite_id() :
 443              $name = esc_html__( 'Users', 'bbpress' );
 444              break;
 445          case bbp_get_user_favorites_rewrite_id() :
 446              $name = esc_html__( 'Favorites', 'bbpress' );
 447              break;
 448          case bbp_get_user_subscriptions_rewrite_id() :
 449              $name = esc_html__( 'Subscriptions', 'bbpress' );
 450              break;
 451          case bbp_get_user_engagements_rewrite_id() :
 452              $name = esc_html__( 'Engagements', 'bbpress' );
 453              break;
 454          default :
 455              $name = ucwords( $component );
 456              break;
 457      }
 458  
 459      return $name;
 460  }
 461  
 462  /**
 463   * Maybe translate a repair tool overhead name
 464   *
 465   * @since 2.6.0 bbPress (r6894)
 466   *
 467   * @param string $version
 468   * @return string
 469   */
 470  function bbp_admin_repair_tool_translate_version( $version = '' ) {
 471  
 472      // Get the version
 473      switch ( $version ) {
 474          case '2.5' :
 475          case '2.5.0' :
 476              $name = esc_html__( '2.5.0', 'bbpress' );
 477              break;
 478          case '2.6' :
 479          case '2.6.0' :
 480              $name = esc_html__( '2.6.0', 'bbpress' );
 481              break;
 482          default :
 483              $name = sanitize_text_field( $version );
 484              break;
 485      }
 486  
 487      return $name;
 488  }
 489  
 490  /** Lists *********************************************************************/
 491  
 492  /**
 493   * Get the array of the repairs to show in a list table.
 494   *
 495   * Uses known filters to reduce the registered results down to the most finite
 496   * set of tools.
 497   *
 498   * @since 2.0.0 bbPress (r2613)
 499   *
 500   * @return array Repair list of options
 501   */
 502  function bbp_admin_repair_list( $type = 'repair' ) {
 503  
 504      // Define empty array
 505      $repair_list = array();
 506  
 507      // Get the available tools
 508      $list      = bbp_get_admin_repair_tools( $type );
 509      $search    = ! empty( $_GET['s']          ) ? stripslashes( $_GET['s']              ) : '';
 510      $overhead  = ! empty( $_GET['overhead']   ) ? sanitize_key( $_GET['overhead']       ) : '';
 511      $component = ! empty( $_GET['components'] ) ? sanitize_key( $_GET['components']     ) : '';
 512      $version   = ! empty( $_GET['version']    ) ? sanitize_text_field( $_GET['version'] ) : '';
 513  
 514      // Overhead filter
 515      if ( ! empty( $overhead ) ) {
 516          $list = wp_list_filter( $list, array( 'overhead' => $overhead ) );
 517      }
 518  
 519      if ( count( $list ) ) {
 520  
 521          // Loop through and key by priority for sorting
 522          foreach ( $list as $id => $tool ) {
 523  
 524              // Component filter
 525              if ( ! empty( $component ) ) {
 526                  if ( ! in_array( $component, (array) $tool['components'], true ) ) {
 527                      continue;
 528                  }
 529              }
 530  
 531              // Version filter
 532              if ( ! empty( $version ) ) {
 533                  if ( ! in_array( $version, (array) $tool['version'], true ) ) {
 534                      continue;
 535                  }
 536              }
 537  
 538              // Search
 539              if ( ! empty( $search ) ) {
 540                  if ( ! strstr( strtolower( $tool['title'] ), strtolower( $search ) ) ) {
 541                      continue;
 542                  }
 543              }
 544  
 545              // Add to repair list
 546              $repair_list[ $tool['priority'] ] = array(
 547                  'id'          => sanitize_key( $id ),
 548                  'type'        => $tool['type'],
 549                  'title'       => $tool['title'],
 550                  'description' => $tool['description'],
 551                  'callback'    => $tool['callback'],
 552                  'overhead'    => $tool['overhead'],
 553                  'version'     => $tool['version'],
 554                  'components'  => $tool['components'],
 555              );
 556          }
 557      }
 558  
 559      // Sort
 560      ksort( $repair_list );
 561  
 562      // Filter & return
 563      return (array) apply_filters( 'bbp_repair_list', $repair_list );
 564  }
 565  
 566  /**
 567   * Get filter links for components for a specific admin repair tool
 568   *
 569   * @since 2.6.0 bbPress (r5885)
 570   *
 571   * @param array $item
 572   * @return array
 573   */
 574  function bbp_get_admin_repair_tool_components( $item = array() ) {
 575  
 576      // Get the tools URL
 577      $tools_url = bbp_get_admin_repair_tool_page_url();
 578  
 579      // Define links array
 580      $links      = array();
 581      $components = ! empty( $item['components'] )
 582          ? (array) $item['components']
 583          : array();
 584  
 585      // Loop through tool components and build links
 586      if ( count( $components ) ) {
 587          foreach ( $components as $component ) {
 588              $args       = array( 'components' => $component );
 589              $filter_url = add_query_arg( $args, $tools_url );
 590              $name       = bbp_admin_repair_tool_translate_component( $component );
 591              $links[]    = '<a href="' . esc_url( $filter_url ) . '">' . esc_html( $name ) . '</a>';
 592          }
 593  
 594      // No components, so return a dash
 595      } else {
 596          $links[] = '&mdash;';
 597      }
 598  
 599      // Filter & return
 600      return (array) apply_filters( 'bbp_get_admin_repair_tool_components', $links, $item );
 601  }
 602  
 603  /**
 604   * Get filter links for versions for a specific admin repair tool
 605   *
 606   * @since 2.6.0 bbPress (r6894)
 607   *
 608   * @param array $item
 609   * @return array
 610   */
 611  function bbp_get_admin_repair_tool_version( $item = array() ) {
 612  
 613      // Get the tools URL
 614      $tools_url = bbp_get_admin_repair_tool_page_url();
 615  
 616      // Define links array
 617      $links    = array();
 618      $versions = ! empty( $item['version'] )
 619          ? (array) $item['version']
 620          : array();
 621  
 622      // Loop through tool versions and build links
 623      if ( count( $versions ) ) {
 624          foreach ( $versions as $version ) {
 625              $args       = array( 'version' => $version );
 626              $filter_url = add_query_arg( $args, $tools_url );
 627              $name       = bbp_admin_repair_tool_translate_version( $version );
 628              $links[]    = '<a href="' . esc_url( $filter_url ) . '">' . esc_html( $name ) . '</a>';
 629          }
 630  
 631      // No versions, so return a dash
 632      } else {
 633          $links[] = '&mdash;';
 634      }
 635  
 636      // Filter & return
 637      return (array) apply_filters( 'bbp_get_admin_repair_tool_version', $links, $item );
 638  }
 639  
 640  /**
 641   * Get filter links for overhead for a specific admin repair tool
 642   *
 643   * @since 2.6.0 bbPress (r5885)
 644   *
 645   * @param array $item
 646   * @return array
 647   */
 648  function bbp_get_admin_repair_tool_overhead( $item = array() ) {
 649  
 650      // Get the tools URL
 651      $tools_url = bbp_get_admin_repair_tool_page_url();
 652  
 653      // Define links array
 654      $links     = array();
 655      $overheads = ! empty( $item['overhead'] )
 656          ? (array) $item['overhead']
 657          : array();
 658  
 659      // Loop through tool overhead and build links
 660      if ( count( $overheads ) ) {
 661          foreach ( $overheads as $overhead ) {
 662              $args       = array( 'overhead' => $overhead );
 663              $filter_url = add_query_arg( $args, $tools_url );
 664              $name       = bbp_admin_repair_tool_translate_overhead( $overhead );
 665              $links[]    = '<a href="' . esc_url( $filter_url ) . '">' . esc_html( $name ) . '</a>';
 666          }
 667  
 668      // No overhead, so return a single dash
 669      } else {
 670          $links[] = '&mdash;';
 671      }
 672  
 673      // Filter & return
 674      return (array) apply_filters( 'bbp_get_admin_repair_tool_overhead', $links, $item );
 675  }
 676  
 677  /** Overhead ******************************************************************/
 678  
 679  /**
 680   * Output filter links for overheads for a specific admin repair tool
 681   *
 682   * @since 2.6.0 bbPress (r5885)
 683   *
 684   * @param array $args
 685   */
 686  function bbp_admin_repair_tool_overhead_filters( $args = array() ) {
 687      echo bbp_get_admin_repair_tool_overhead_filters( $args );
 688  }
 689  
 690  /**
 691   * Get filter links for overheads for a specific admin repair tool
 692   *
 693   * @since 2.6.0 bbPress (r5885)
 694   *
 695   * @param array $args
 696   * @return array
 697   */
 698  function bbp_get_admin_repair_tool_overhead_filters( $args = array() ) {
 699  
 700      // Parse args
 701      $r = bbp_parse_args( $args, array(
 702          'before'       => '<ul class="subsubsub">',
 703          'after'        => '</ul>',
 704          'link_before'  => '<li>',
 705          'link_after'   => '</li>',
 706          'count_before' => ' <span class="count">(',
 707          'count_after'  => ')</span>',
 708          'sep'          => ' | ',
 709  
 710          // Retired, use 'sep' instead
 711          'separator'    => false
 712      ), 'get_admin_repair_tool_overhead_filters' );
 713  
 714      /**
 715       * Necessary for backwards compatibility
 716       * @see https://bbpress.trac.wordpress.org/ticket/2900
 717       */
 718      if ( ! empty( $r['separator'] ) ) {
 719          $r['sep'] = $r['separator'];
 720      }
 721  
 722      // Count the tools
 723      $tools = bbp_get_admin_repair_tools( bbp_get_admin_repair_tool_page_id() );
 724  
 725      // Get the tools URL
 726      $tools_url = bbp_get_admin_repair_tool_page_url();
 727  
 728      // Define arrays
 729      $overheads = $links = array();
 730  
 731      // Loop through tools and count overheads
 732      if ( count( $tools ) ) {
 733          foreach ( $tools as $tool ) {
 734  
 735              // Get the overhead level
 736              $overhead = $tool['overhead'];
 737  
 738              // Set an empty count
 739              if ( empty( $overheads[ $overhead ] ) ) {
 740                  $overheads[ $overhead ] = 0;
 741              }
 742  
 743              // Bump the overhead count
 744              $overheads[ $overhead ]++;
 745          }
 746      }
 747  
 748      // Get the current overhead, if any
 749      $selected = ! empty( $_GET['overhead'] )
 750          ? sanitize_key( $_GET['overhead'] )
 751          : '';
 752  
 753      // Create the "All" link
 754      $current = empty( $selected ) ? 'current' : '';
 755      $links[] = $r['link_before'] . '<a href="' . esc_url( $tools_url ) . '" class="' . esc_attr( $current ) . '">' . sprintf( esc_html__( 'All %s', 'bbpress' ), $r['count_before'] . count( $tools ) . $r['count_after'] ) . '</a>' . $r['link_after'];
 756  
 757      // Loop through overheads and created links
 758      if ( count( $overheads ) ) {
 759  
 760          // Sort
 761          ksort( $overheads );
 762  
 763          // Loop through overheads and build filter
 764          foreach ( $overheads as $overhead => $count ) {
 765  
 766              // Build the filter URL
 767              $key        = sanitize_key( $overhead );
 768              $args       = array( 'overhead' => $key );
 769              $filter_url = add_query_arg( $args, $tools_url );
 770  
 771              // Figure out separator and active class
 772              $current  = ( $selected === $key )
 773                  ? 'current'
 774                  : '';
 775  
 776              // Counts to show
 777              if ( ! empty( $count ) ) {
 778                  $overhead_count = $r['count_before'] . $count . $r['count_after'];
 779              }
 780  
 781              // Build the link
 782              $links[] = $r['link_before'] . '<a href="' . esc_url( $filter_url ) . '" class="' . esc_attr( $current ) . '">' . bbp_admin_repair_tool_translate_overhead( $overhead ) . $overhead_count . '</a>' . $r['link_after'];
 783          }
 784      }
 785  
 786      // Surround output with before & after strings
 787      $output = $r['before'] . implode( $r['sep'], $links ) . $r['after'];
 788  
 789      // Filter & return
 790      return apply_filters( 'bbp_get_admin_repair_tool_components', $output, $r, $args );
 791  }


Generated: Mon Jul 22 01:01:32 2019 Cross-referenced by PHPXref 0.7.1