How can I add new attributes in a Class when my addon is active?

You need to declare a location for this data in your class, like an array beforehand and then use it like below: class test { private $first_name; private $data = array(); public function __set($name, $value) { $this->data[$name] = $value; } public function __get($name) { if (array_key_exists($name, $this->data)) return $this->data[$name]; else return ‘not found’; } } … Read more

$GLOBALS & global doesn’t work [closed]

In my opinion you shouldn’t use $GLOBALS at all. add_filter shouldn’t be used the way you are using it. So there is apply_filter in wordpress that returns a filtered value such that $my_variable = apply_filter(‘my_filter_tag’, ‘default_value’, $arg1); In the above code ‘default_value’ can be anything. $my_variable will hold the value ‘default_value’ if no one called … Read more

admin_post hook not working

You’re missing a ‘ in your code and your function name is different. function my_maybe_add_redirect( $entry, $form ) { wp_redirect( ‘https://www.google.com/’, 301 ); exit(); } add_action( ‘admin_post_submit_images’, ‘my_maybe_add_redirect’, 10, 2 );

change position of element using hook [closed]

Instead of adding and removing the hooks like this. You should do the work on some action/hook. which gets fire before these hooks. so you can call it in this way add_action( ‘init’ , ‘sf_change_header_position’ , 10 ); function sf_change_header_position() { remove_action( ‘storefront_header’, ‘storefront_secondary_navigation’, 30 ); add_action( ‘storefront_header’, ‘storefront_secondary_navigation’, 52 ); }

Transform .wp-video to the native video player of the browser

I’ve found the right way digging through the WP documentation: https://developer.wordpress.org/reference/hooks/wp_video_shortcode/ This code seems to do the trick: function buildVideoPlayer($output, $attr) { // $output contains the default HTML string, created by the WP core // $attr is an associative array, which contains the parameters // (src, poster, preload, etc.) specified in the shortcode // The … Read more