[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/gp-includes/ -> system.php (source)

   1  <?php
   2  
   3  function gp_urldecode_deep($value) {
   4      $value = is_array( $value ) ? array_map( 'gp_urldecode_deep', $value ) : urldecode( $value );
   5      return $value;
   6  }
   7  
   8  /**
   9   * Makes all key/value pairs in $vars global variables
  10   */
  11  function gp_set_globals( $vars ) {
  12      foreach( $vars as $name => $value ) {
  13          $GLOBALS[ $name ] = $value;
  14      }
  15  }
  16  
  17  /**
  18   * Initializes rewrite rules and provides the 'gp_init' action.
  19   *
  20   * @since 1.0.0
  21   */
  22  function gp_init() {
  23      gp_rewrite_rules();
  24  
  25      /**
  26       * Fires after GlotPress has finished loading but before any headers are sent.
  27       *
  28       * @since 1.0.0
  29       */
  30      do_action( 'gp_init' );
  31  }
  32  
  33  /**
  34   * Fires during the WP parse_request hook to check to see if we're on a GlotPress page, if so
  35   * we can abort the main WP_Query logic as we won't need it in GlotPress.
  36   * a matching page.
  37   *
  38   * @since 1.0.0
  39   */
  40  function gp_parse_request() {
  41      if ( is_glotpress() ) {
  42          add_filter( 'posts_request', 'gp_abort_main_wp_query', 10, 2 );
  43      }
  44  }
  45  
  46  /**
  47   * Prevents executing WP_Query's default queries on GlotPress requests.
  48   *
  49   * The following code effectively avoid running the main WP_Query queries by setting values before
  50   * they are run.
  51   *
  52   * @link http://wordpress.stackexchange.com/a/145386/40969 Original source.
  53   *
  54   * @since 1.0.0
  55   *
  56   * @param array    $sql  The complete SQL query.
  57   * @param WP_Query $wp_query The WP_Query instance (passed by reference).
  58   * @return string|false False if GlotPress request, SQL query if not.
  59   */
  60  function gp_abort_main_wp_query( $sql, WP_Query $wp_query ) {
  61      if ( $wp_query->is_main_query() ) {
  62          // Prevent SELECT FOUND_ROWS() query.
  63          $wp_query->query_vars['no_found_rows'] = true;
  64  
  65          // Prevent post term and meta cache update queries.
  66          $wp_query->query_vars['cache_results'] = false;
  67  
  68          return false;
  69      }
  70  
  71      return $sql;
  72  }
  73  
  74  /**
  75   * Deletes user's permissions when they are deleted from WordPress
  76   * via WP's 'deleted_user' action.
  77   *
  78   * @since 1.0.0
  79   */
  80  function gp_delete_user_permissions( $user_id ) {
  81      $permissions = GP::$permission->find_many( array( 'user_id' => $user_id ) );
  82  
  83      foreach( $permissions as $permission ) {
  84          $permission->delete();
  85      }
  86  }


Generated: Mon Oct 21 01:01:55 2019 Cross-referenced by PHPXref 0.7.1