Jump to content

David-London

New Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by David-London

  1. I have upgraded to PHP8.o and have a plugin using the depreciated each() function. Would this be a correct refactor of this code? -- see the inline comments where I have made the changes // get the importable types $types = $this -> get_importable_post_types(); settype($types, 'array'); // I added this line if ( ! $types ) : _e('Sorry, there are no public post types that support post thumbnails.', 'plugin_default'); return; endif; _e('The default post type for new posts will be ', 'plugin_default'); if ( count($types) == 1 ): // only one so no need for selector // list($post_type, $post_type_name) = each($types); // I have taken this line out $post_type = key($types); // I added this line $post_type_name = current($types); // I added this line ?> Thanks for your help
  2. OK - thanks for reply. This is a plugin which I didn't write so I am just trying to update it. Just above the code this comment is written: // If there are sources, show a box of recently added Maybe I could replace that line of code with: Here is more of the code ... // If there are sources, show a box of recently added if ( count($this::$sources) > 0 ) : ?> <div id="tube-vc-recent-channels-module"> <h3> <?php _e( 'Recently added Channels &amp; Playlists', 'yt-revolution' ); ?> </h3> <ul style="list-style: none; padding-left:.25em;"> <?php $count = 0; foreach ( $this::$sources as $source ): $count++; if ( $count > 5 ): continue; endif;
  3. Hi all, I have recently upgraded to php 8.0 and some of the scripts in a wordpress plugin now don't work. One of them is because of count needing to be an array. Should I just change this code to this ? If not, what would be the correct sintax? Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.