Look for image by class and set as featured image bulk

I’m new here and I have zero knowledge of coding so I hope you can help me.

I migrated an old website to new wordpress one and used a plugins to set first image of posts as featured image. but featured image of some posts for some reason i don’t know are not the first image of the post. so i decided to fix this by coding.

All my first images of the posts has a class name which is "worpresspic". I want that code looks in posts for images that has the class I mentioned above and sets that as post’s featured image despite the post already has featured image or not. i found this regex that seems work perfect at finding the image:

(<img(.*class=['\"](.*)worpresspic(.*)['\"].*)*\/>)+ 

I found this code that look for first image and sets it as featured image as well:

// Get URL of first image in a post    function catch_that_image() {    global $  post, $  posts;    $  first_img = '';    ob_start();    ob_end_clean();    $  output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $  post->post_content,      $  matches);    $  first_img = $  matches [1] [0];     // no image found display default image instead    if(empty($  first_img)){    $  first_img = "/images/default.jpg";    }    return $  first_img;    } 

and also the below code which seems has more options:

// Note that your theme must support post thumbnails for this function to work.  // If you are getting an error try adding add_theme_support('post-thumbnails'); to your functions. php file   function vp_get_thumb_url($  text, $  size){     global $  post;     $  imageurl="";      // Check to see which image is set as "Featured Image"     $  featuredimg = get_post_thumbnail_id($  post->ID);     // Get source for featured image     $  img_src = wp_get_attachment_image_src($  featuredimg, $  size);     // Set $  imageurl to Featured Image     $  imageurl=$  img_src[0];      // If there is no "Featured Image" set, move on and get the first image attached to the post     if (!$  imageurl) {         // Extract the thumbnail from the first attached imaged         $  allimages =&get_children('post_type=attachment&post_mime_type=image&post_parent=' . $  post->ID );          foreach ($  allimages as $  img){             $  img_src = wp_get_attachment_image_src($  img->ID, $  size);             break;         }         // Set $  imageurl to first attached image         $  imageurl=$  img_src[0];     }      // If there is no image attached to the post, look for anything that looks like an image and get that     if (!$  imageurl) {         preg_match('/<\s*img [^\>]*src\s*=\s*[\""\']?([^\""\'>]*)/i' ,  $  text, $  matches);         $  imageurl=$  matches[1];     }      // If there's no image attached or inserted in the post, look for a YouTube video     if (!$  imageurl){         // look for traditional youtube.com url from address bar         preg_match("/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $  text, $  matches2);         $  youtubeurl = $  matches2[0];         $  videokey = $  matches2[3];     if (!$  youtubeurl) {         // look for youtu.be 'embed' url         preg_match("/([a-zA-Z0-9\-\_]+\.|)youtu\.be\/([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $  text, $  matches2);         $  youtubeurl = $  matches2[0];         $  videokey = $  matches2[2];     }     if ($  youtubeurl)         // Get the thumbnail YouTube automatically generates         // '0' is the biggest version, use 1 2 or 3 for smaller versions         $  imageurl = "http://i.ytimg.com/vi/{$  videokey}/0.jpg";     }      // Spit out the image path     return $  imageurl; } 

But as I said I have no coding knowledge and don’t know how to edit these codes to match my needs. For example this codes check if the post has featured image or not and if the post has featured image nothing happens, but i don’t want this.

Also I want to run it in wordpress and without need to open each post and save, all featured images of the posts being updated. where to put the code? what php code I need to add and where can i put the final code? (as i know it must be functions.php am i right?)

Thank you for your help.

Cronjob not firing function within class that extends WC_Email

I’m really frustrated right now, because I just can’t seem to figure out what’s wrong here. Maybe it’s something really simple and I’m just stuck somewhere. Please help me out!

I’m working on a small plugin to add a payment reminder to WooCommerce. I added a wp_schedule_event (nd_payment_reminder) to the activation hook. This works so far.

In my main plugin file I’m including my class which looks a little like this:

class ND_Payment_Due extends WC_Email { public function __construct() {         parent::__construct();         add_action('nd_payment_reminder', array($  this, 'getOpenOrders')); }  public function getOpenOrders() {         // getting data and triggering the email } [...] } 

Whatever I try, the function getOpenOrders seems not to be started. I’ve copied this plugin from another website where I originally used it and it still works there – so I’m really confused right now.

I tested it from the functions.php – this works:

add_action('nd_payment_reminder', 'testfunction'); 

I also thought my getOpenOrders()-Function might be faulty, but even when I use another simple function from within my class it’s just not working. 🙁

Any ideas would be highly appreciated! Thanks in advance!

Where to use Post class in a real theme, title, content or parent div or article tag?

I am extending discussion from one another article posted on the same website → Where should I use post_class()?.

This is the portion from content-single.php →

enter image description here

Where should I put the post-class? in the h2 tag that will print the title or on the parent article tag, which has one other div,which is a sibling to h2, title class?

  <h4><?php the_title(); ?></h4>   <p><?php the_content(); ?></p> 

I browsed this link, but still, I could not get the clarity → https://developer.wordpress.org/reference/functions/post_class/

REQUIRED: Could not find post_class. See: post_class <div id="post-" >

Trying to get player movement from a class [closed]

I working on my game for the Ludum dare 48 game jam. I decided to learn raylib, the c++ version, to make a game. But my player code doesn’t even work. I have two files:
main.cpp:

#include "raylib.h"  int main() {     const int windowWidth = 1200;     const int windowHeight = 720;     InitWindow(windowWidth, windowHeight, "Ludum Dare 48");     /*Player*/     Player ply;     /*end of Player */     int rot = 0;     int increment = 1;     SetTargetFPS(60);     while (!WindowShouldClose()) {         BeginDrawing();         ClearBackground(RAYWHITE);                  ply.yes(windowWidth/2, windowHeight-50, 30,30);         EndDrawing();     } } 

and player.cpp

#include "raylib.h" class Player {     public:     int playerX;     int playerY;     void yes(int x, int y, int sizeX, int sizeY);     void input();              }; void Player::yes(int x, int y, int sizeX, int sizeY) {     DrawRectangle(x,y,sizeX,sizeY, RED);     if (IsKeyDown(KEY_RIGHT)) {             x++;         }         if (IsKeyDown(KEY_LEFT)) {             x--;         } } 

I get the error:
cc1plus.exe: warning: command line option '-std=c99' is valid for C/ObjC but not for C++

it looks like a compiler error, not an error in my code, but when the class is removed the code runs fine.

Question regarding Pact magic with multiclassing and a class specific bonus

I play a 6 bard/ 4 warlock multiclass. My character recently obtained a rhythm makers drum +3, giving a +3 bonus to my bard spells’ DC and rolls.

I am curious if I were to cast a spell I had taken on my warlock list (hold person) with a bard spell slot, would the bonus increase the DC? DnDB added the bonus to all my characters spells (I know that isn’t right) but thought it may be applicable if a spell is on both lists.

Thank you in advance.

Is Additional Fighting Style underpowered as the only class feature at a given level?

This question is inspired by considering minor homebrew improvements to the Champion subclass, which is frequently but not universally considered a weak subclass.

Looking at the class features, the following occurred to me about Additional Fighting Style (level 10):

  1. Most fighting styles don’t synergize. The main exception is taking both a defensive and offensive fighting style, leading to common recommendations of Defense as the go-to choice for level 10 Champions.
  2. Every class that gets a first fighting style gets additional features at that level (e.g. Spellcasting for level 2 Paladins and Rangers).

So Additional Fighting Style by itself seems pretty weak compared to the level 10 features of other fighter subclasses. Hence the question.

Can one class’ feature help another class qualify for a feature?

It’s best to just give an example for this:

Let’s say I have levels in a rogue archetype that gives up Evasion, but I take a two level dip into monk to get Evasion. Would I qualify for the Improved Evasion advanced talent upon reaching rogue level 10? (yes, I know RAW Improved Evasion has no Evasion prerequisite but I doubt most GMs would let you get away with taking it without Evasion)

Or if I had levels in an alchemist archetype that gave up Mutagen, but took a dip in Mutagenic Mauler or Mutation Warrior, could I take alchemist discoveries that affect mutagens, as an alchemist, and apply them to the dip class’ Mutagen?

Which class gives most new magical powers for 1 level dip

Background: I have a bard, who is a bit lacking in low level spell selection, so I’ve been looking into multiclassing to get some more.

Stats (you can give +2 ASI for the benefit of multiclassing):

STR 11, DEX 17, CON 14, INT 9, WIS 14, CHA 20

So, Wizard is out.

For classes that pick subclass at level 1, subclass features count of course.

From what I have gathered from unofficial internet snippets, Tasha’s Cauldron of Everything seems give some nice options (like 4 cantrips and 5 1st level spells?!). But I don’t have that book myself to verify, and I may have missed other options, so the question:

What is the most different spells or spell-like powers a 1-level multiclass dip can give?

To clarify: I mean spells the character can actually have available, not the number they can choose from. I also realize now, that divine casters who pick spells every morning are their own category, not directly comparable. Still, for purposes of this Q, count the daily prepared spells.

Bard isn’t option for me, so I’ll include it as an example: 4 cantrips, 2 spells, 1 magical ability (Bardic Inspiration).

UA is ok, though I’d prefer official classes.