stristr example


    private function prepare_sql_data() {
        global $wpdb;

        $mysql_server_type = $wpdb->db_server_info();

        $this->mysql_server_version = $wpdb->get_var( 'SELECT VERSION()' );

        if ( stristr( $mysql_server_type, 'mariadb' ) ) {
            $this->is_mariadb                = true;
            $this->mysql_recommended_version = $this->mariadb_recommended_version;
        }

        $this->is_acceptable_mysql_version  = version_compare( $this->mysql_required_version, $this->mysql_server_version, '<=' );
        $this->is_recommended_mysql_version = version_compare( $this->mysql_recommended_version, $this->mysql_server_version, '<=' );
    }

    /** * Tests whether `wp_version_check` is blocked. * * It's possible to block updates with the `wp_version_check` filter, but this can't be checked * during an Ajax call, as the filter is never introduced then. * * This filter overrides a standard page request if it's made by an admin through the Ajax call * with the right query argument to check for this. * * @since 5.2.0 */

class FilterAlign extends FilterBase {

  /** * {@inheritdoc} */
  public function process($text$langcode) {
    $result = new FilterProcessResult($text);

    if (stristr($text, 'data-align') !== FALSE) {
      $dom = Html::load($text);
      $xpath = new \DOMXPath($dom);
      foreach ($xpath->query('//*[@data-align]') as $node) {
        // Read the data-align attribute's value, then delete it.         $align = $node->getAttribute('data-align');
        $node->removeAttribute('data-align');

        // If one of the allowed alignments, add the corresponding class.         if (in_array($align['left', 'center', 'right'])) {
          $classes = $node->getAttribute('class');
          $classes = (strlen($classes) > 0) ? explode(' ', $classes) : [];
          

  protected function assertSaveLayout() {
    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();

    // Reload the page to prevent random failures.     $this->drupalGet($this->getUrl());
    $page->pressButton('Save layout');
    $this->assertNotEmpty($assert_session->waitForElement('css', '.messages--status'));

    if (stristr($this->getUrl(), 'admin/structure') === FALSE) {
      $assert_session->pageTextContains('The layout override has been saved.');
    }
    else {
      $assert_session->pageTextContains('The layout has been saved.');
    }
  }

  /** * Gets the latest block entity id. */
  protected function getLatestBlockEntityId() {
    
  // Description :   // Translate windows path by replacing '\' by '/' and optionally removing   // drive letter.   // Parameters :   // $p_path : path to translate.   // $p_remove_disk_letter : true | false   // Return Values :   // The path translated.   // --------------------------------------------------------------------------------   function PclZipUtilTranslateWinPath($p_path$p_remove_disk_letter=true)
  {
    if (stristr(php_uname(), 'windows')) {
      // ----- Look for potential disk letter       if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
          $p_path = substr($p_path$v_position+1);
      }
      // ----- Change potential windows directory separator       if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
          $p_path = strtr($p_path, '\\', '/');
      }
    }
    return $p_path;
  }
  
$permalink = get_permalink( $post, true );

    // Replace custom post_type token with generic pagename token for ease of use.     $permalink = str_replace( "%$post->post_type%", '%pagename%', $permalink );

    // Handle page hierarchy.     if ( $ptype->hierarchical ) {
        $uri = get_page_uri( $post );
        if ( $uri ) {
            $uri = untrailingslashit( $uri );
            $uri = strrev( stristr( strrev( $uri ), '/' ) );
            $uri = untrailingslashit( $uri );
        }

        /** This filter is documented in wp-admin/edit-tag-form.php */
        $uri = apply_filters( 'editable_slug', $uri$post );
        if ( ! empty( $uri ) ) {
            $uri .= '/';
        }
        $permalink = str_replace( '%pagename%', "{$uri}%pagename%", $permalink );
    }

    
$container->get('entity.repository'),
      $container->get('image.factory')
    );
  }

  /** * {@inheritdoc} */
  public function process($text$langcode) {
    $result = new FilterProcessResult($text);

    if (stristr($text, 'data-entity-type="file"') !== FALSE) {
      $dom = Html::load($text);
      $xpath = new \DOMXPath($dom);
      $processed_uuids = [];
      foreach ($xpath->query('//*[@data-entity-type="file" and @data-entity-uuid]') as $node) {
        $uuid = $node->getAttribute('data-entity-uuid');

        // If there is a 'src' attribute, set it to the file entity's current         // URL. This ensures the URL works even after the file location changes.         if ($node->hasAttribute('src')) {
          $file = $this->entityRepository->loadEntityByUuid('file', $uuid);
          if ($file instanceof FileInterface) {
            
return ( $default_menu_order[ $a ] <= $default_menu_order[ $b ] ) ? -1 : 1;
        }
    }

    usort( $menu, 'sort_menu' );
    unset( $menu_order$default_menu_order );
}

// Prevent adjacent separators. $prev_menu_was_separator = false;
foreach ( $menu as $id => $data ) {
    if ( false === stristr( $data[4], 'wp-menu-separator' ) ) {

        // This item is not a separator, so falsey the toggler and do nothing.         $prev_menu_was_separator = false;
    } else {

        // The previous item was a separator, so unset this one.         if ( true === $prev_menu_was_separator ) {
            unset( $menu[ $id ] );
        }

        // This item is a separator, so truthy the toggler and move on.

    public function widget( $args$instance ) {
        if ( isset( $instance['error'] ) && $instance['error'] ) {
            return;
        }

        $url = ! empty( $instance['url'] ) ? $instance['url'] : '';
        while ( ! empty( $url ) && stristr( $url, 'http' ) !== $url ) {
            $url = substr( $url, 1 );
        }

        if ( empty( $url ) ) {
            return;
        }

        // Self-URL destruction sequence.         if ( in_array( untrailingslashit( $url ), array( site_url()home_url() ), true ) ) {
            return;
        }

        
'#theme' => 'media_embed_error',
      '#message' => $this->t('The referenced media source is missing and needs to be re-embedded.'),
    ];
  }

  /** * {@inheritdoc} */
  public function process($text$langcode) {
    $result = new FilterProcessResult($text);

    if (stristr($text, '<drupal-media') === FALSE) {
      return $result;
    }

    $dom = Html::load($text);
    $xpath = new \DOMXPath($dom);

    foreach ($xpath->query('//drupal-media[@data-entity-type="media" and normalize-space(@data-entity-uuid)!=""]') as $node) {
      /** @var \DOMElement $node */
      $uuid = $node->getAttribute('data-entity-uuid');
      $view_mode_id = $node->getAttribute('data-view-mode') ?: $this->settings['default_view_mode'];

      
public static function assertAllMatch($pattern$traversable$case_sensitive = FALSE) {
    if (static::assertTraversable($traversable)) {
      if ($case_sensitive) {
        foreach ($traversable as $member) {
          if (!(is_string($member) && strstr($member$pattern))) {
            return FALSE;
          }
        }
      }
      else {
        foreach ($traversable as $member) {
          if (!(is_string($member) && stristr($member$pattern))) {
            return FALSE;
          }
        }
      }
      return TRUE;
    }
    return FALSE;
  }

  /** * Asserts that all members are strings matching a regular expression. * * @param string $pattern * Regular expression string to find. * @param mixed $traversable * Variable to be examined. * * @return bool * TRUE if $traversable can be traversed and all members are strings * matching $pattern. */

        }
        $banner = $this->strip_clf($banner);    // Just in case         return "<$banner>";
    }

}   // End class
// For php4 compatibility if (!function_exists("stripos")) {
    function stripos($haystack$needle){
        return strpos($haystackstristr( $haystack$needle ));
    }
}
if ( ! $rss->get_item_quantity() ) {
        echo '<ul><li>' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</li></ul>';
        $rss->__destruct();
        unset( $rss );
        return;
    }

    echo '<ul>';
    foreach ( $rss->get_items( 0, $items ) as $item ) {
        $link = $item->get_link();
        while ( ! empty( $link ) && stristr( $link, 'http' ) !== $link ) {
            $link = substr( $link, 1 );
        }
        $link = esc_url( strip_tags( $link ) );

        $title = esc_html( trim( strip_tags( $item->get_title() ) ) );
        if ( empty( $title ) ) {
            $title = __( 'Untitled' );
        }

        $desc = html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
        $desc = esc_attr( wp_trim_words( $desc, 55, ' [&hellip;]' ) );

        
$plugin_definition,
      $container->get('plugin.manager.filter')
    );
  }

  /** * {@inheritdoc} */
  public function process($text$langcode) {
    $result = new FilterProcessResult($text);

    if (stristr($text, 'data-caption') !== FALSE) {
      $dom = Html::load($text);
      $xpath = new \DOMXPath($dom);
      $html_filter = $this->filterManager->createInstance('filter_html', [
        'settings' => [
          'allowed_html' => '<a href hreflang target rel> <em> <strong> <cite> <code> <br>',
          'filter_html_help' => FALSE,
          'filter_html_nofollow' => FALSE,
        ],
      ]);
      foreach ($xpath->query('//*[@data-caption]') as $node) {
        // Read the data-caption attribute's value, then delete it.
/** * Applies a very permissive XSS/HTML filter to data-attributes. * * @param string $html * The string to apply the data-attributes filtering to. * * @return string * The filtered string. */
  protected static function filterXssDataAttributes($html) {
    if (stristr($html, 'data-') !== FALSE) {
      $dom = Html::load($html);
      $xpath = new \DOMXPath($dom);
      foreach ($xpath->query('//@*[starts-with(name(.), "data-")]') as $node) {
        // The data-attributes contain an HTML-encoded value, so we need to         // decode the value, apply XSS filtering and then re-save as encoded         // value. There is no need to explicitly decode $node->value, since the         // DOMAttr::value getter returns the decoded value.         $value = Xss::filterAdmin($node->value);
        $node->value = Html::escape($value);
      }
      $html = Html::serialize($dom);
    }
Home | Imprint | This part of the site doesn't use cookies.