Questions tagged [oop]

The tag has no usage guidance, but it has a tag wiki.

Filter by
Sorted by
Tagged with
0 votes
0 answers
24 views

Overwrite WordPress Plugin Class Function

I just want to customize the inline style of the div-element. The function looks like this: class class_eqw_product{ //other code here function add_loop_enquiry_button() { global $product; ...
Thomas's user avatar
  • 1
0 votes
0 answers
34 views

Wordpress Action Hook inside Classes

The WordPress plugin is functioning correctly, and within the functions.php file, I aim to establish tabs using arguments and hooks. These tabs should consist of both a tab menu and tab content. ...
aldin_abdagic's user avatar
0 votes
0 answers
20 views

$wpdb->insert writes a record twice for some reason, when my custom developed plugin calls my class function once

My custom code in my custom (class-based) plugin for some reason, writes the same record twice, when as you can see it's called once. This double write also happens even when I do the same type of ...
Mario's user avatar
  • 1
0 votes
1 answer
47 views

How to use filter in this situation, can not modify the structure using filter

plugins/idx-broker-platinum/idx/shortcodes/register-impress-shortcodes.php This is the plugin file where I need to use a filter to override the structure. Filter name: impress_showcase_property_html ...
Ravi's user avatar
  • 247
0 votes
1 answer
22 views

How can I modify or filter this variable in an existing class? (Mai Theme)

I'm trying to utilize existing post-grid functions to show attachment posts but $post_status is hard coded to be either 'publish' or 'private' whereas attachments have a status of inherit. I added '...
fourohfour's user avatar
0 votes
1 answer
213 views

How to get parameters with add_filter with a static method?

I use this add_filters to append some links to each comment: add_filter('comment_text', array($this, 'printModerateLinks')); How do I pass the other attributes in this static method to my method &...
Marc's user avatar
  • 687
0 votes
0 answers
94 views

Function not being called on form submit, only blank admin-post.php page

We are trying to call the function on_save_settings when the form with action settings_form is submitted. But when we submit the form we only get a blank page with url /wp-admin/admin-post.php. Here ...
Jari R's user avatar
  • 1
0 votes
2 answers
390 views

Usage of call back function of add_meta_box()

I am learning WordPress Plugin Development. My Code is like below. class Admin { public function __construct() { add_action( 'admin_menu', [$this,'news_meta_boxes'] ); ...
Foysal's user avatar
  • 417
0 votes
0 answers
45 views

OOP PHP class extends TwentyTwenty_Customize in Child Theme

Not sure if OOP is covered here but i've copied the class-twentytwenty-customize.php file from the Twenty Twenty parent theme to my child theme and renamed it to class-customize.php because i need to ...
Brad Dalton's user avatar
  • 6,906
0 votes
1 answer
365 views

Why is a wp function used in current PHP namespace's callback not resolved to global scope?

Imagine the following script: <?php namespace MySpace; class MyClass { public static function execute() { // Do something post_exists(1,'','','my_post_type'); } } ?> I'm now ...
DevelJoe's user avatar
  • 487
0 votes
1 answer
99 views

How to execute add_action() function from custom plugin to Crontrol plugin or do_action()?

I created a custom plugin and I need to schedule add_action using Crontrol Plugin, the Setup class is from different php class. But the schedule action cant read the Crontrol even if I execute ...
JuniorA's user avatar
0 votes
0 answers
532 views

How to call a function from a shortcode function in an oop plugin

I’m developing an OOP plugin based on WordPress-Plugin-Boilerplate by Devin Vinson. In the includes folder, I’ve created a class for shortcodes: class My_Plugin_Shortcodes { public static ...
jcropp's user avatar
  • 111
0 votes
2 answers
134 views

Extend Wordpress Core Classes in OOP Theme?

What is the best way of using WordPress's core classes in the context of an object-oriented design? I am trying to use $wp_admin_bar to remove a couple of the default WordPress designs but I am not ...
User37849012643's user avatar
0 votes
1 answer
150 views

Call to "admin_notices" hook from a static method

Trying to call "admin_notices" hook from a static function. Getting no output. While normal calling to the same hook is working. use Awraq\Init; use Awraq\Notice; /** * Initialize the ...
Pijush Gupta's user avatar
0 votes
1 answer
71 views

Wordpress Custom Hook with Class method

The code described below works normally outside of wordpress, but in wordpress I get "warning expects parameter 1 to be valid callback function mycars ($ mycarsclass) not found". If I remove ...
deki0's user avatar
  • 1
2 votes
1 answer
103 views

How to do conditional publishing?

I am trying to write a plugin that will stop a user from publishing (or updating) a post if a given condition is not met, for example, if the title of the post is already being used in a different ...
David Valenzuela's user avatar
-1 votes
1 answer
1k views

How to save custom made object in an array in a post meta field

I've made two custom classes: FooBar BarSchizzle I'm making a quite custom calculation of a bunch of things, that I would like to save in an array in a post_meta field. This is how I save it $obj1 = ...
Zeth's user avatar
  • 858
0 votes
0 answers
274 views

FPDF for creating pdf diplomas

Before anything else, I must say I am new on building WordPress functions. I have a website with online courses. Students have to sit exams and at the end they get a score, an average of all the exams....
Andrés's user avatar
0 votes
1 answer
56 views

remove_action: how to access to a method in an child class?

I've this in my main plugin file: $main_admin_class = new MainAdminClass(); $main_admin_class->init(); MainAdminClass has this code: class MainAdminClass { public function init() { $...
Dudo1985's user avatar
  • 223
1 vote
1 answer
41 views

How to prevent XSS alter custom global javascript object & methods in Wordpress

Im working on a project in Wordpress that enqueues multiple .js files where each file adds a new method to a global javascript object, this in order to make the desired methods available only if ...
Pappageorgio's user avatar
0 votes
1 answer
225 views

Bad request 400 using class based files

after digging through a lot of Ajax Bad Request 400 problems here on SO, that, unfortunately, didn't help me to solve this problem. After instantiating my custom post, I add a submenu page where I ...
mybecks's user avatar
  • 351
1 vote
1 answer
255 views

Use object in template part

I try to use a template part in my loop. <?php foreach ($categories as $category) { get_template_part( 'temp-parts/loop/blcnr_loop'); } ?> In the template part I call the object <?php ...
Jop's user avatar
  • 27
0 votes
1 answer
484 views

Plugin Development using classes - Public & Private Callbacks

Alright, so I'm developing a plugin where my plugin file is a class which holds all the functions related to the initiation of the plugin, such that I can simply provide all of the plugins ...
DevelJoe's user avatar
  • 487
0 votes
1 answer
69 views

Is it possible to make get variable out of filter in Class?

I am trying to have a variable out of the filter At the end of there is return apply_filters( 'woocommerce_account_menu_items', $items, $endpoints ); function wc_get_account_menu_items() { $...
GeekyOwl's user avatar
0 votes
1 answer
735 views

Use PHP Class in Wordpress functions

I have a class that I want to use in functions.php but I'm not sure the best way to set it up I also want to get WooCommerce's cart array. I currently do not have access to WC() in my class yet. What ...
bghouse's user avatar
  • 101
2 votes
2 answers
3k views

How do you render_callback for register_block_type to a method in another class?

I'm writing a new plugin, and one of the things it does is create a new dynamic block. I generally write my plugins based off of WPPB, which does things in an object-oriented way, and semantically ...
philolegein's user avatar
0 votes
1 answer
686 views

Why is my custom post type not being activated on plug-in activation?

I am building a very basic plug-in, the template I have created works beautifully. However I am unable to get the custom post type to be built and displayed in the admin panel on activation. The thing ...
Jason Is My Name's user avatar
1 vote
1 answer
1k views

admin_notices action doesn't trigger within save_post action

After the save_post action runs, I'm attempting to also use the admin_notices action and it doesn't work. What am I doing wrong? If I move the admin_notices action into the constructor, it works fine ...
armadadrive's user avatar
0 votes
1 answer
670 views

Cant register rest routs from class instance

I am writing a plugin in OOP PHP for word press I have a problem with rest routes not registering... plugin class: require_once plugin_dir_path( __FILE__ ) . 'inc/org-clients-repository.php'; ...
Isaac Cohen's user avatar
0 votes
1 answer
322 views

can I extend the WP_Query class to deal with 'duplicate' posts created by joining to wp_posts?

Based on the premise that one big database requests is better than many smaller ones, I've modified WP_Query for my custom post type 'word' and joined three tables to it. The resulting query looks ...
guardiancrescent's user avatar
2 votes
2 answers
4k views

How to include and use custom class files in plugin?

I'm entirely new to OOP, but trying to dip my toe in by creating a simple Recipes plugin. I have added a Recipes custom post type and a few meta fields to go along with it, and now I am trying to ...
Ben Aldrich's user avatar
0 votes
0 answers
30 views

Some custom post types did not return an object

I wrote a function to register custom post types below - appetizer (working well) - vermicelli (working well) - pho (working well) - seafoodNoodle (X) - koreanSpecial (X) - koreanRice (X) - lunchBox (...
Jimin Byun's user avatar
0 votes
1 answer
76 views

Use another action instead of the shortcode API to display the last time a user logged in

Here's my problem: if ( !class_exists( 'printSecurity' ) ) { class printSecurity { public $constant_name_prefix = 'PRNSEC_'; public function __construct() { define(...
user3833012's user avatar
1 vote
2 answers
826 views

Trying to get property of non-object

function im_check_term($name,$tax){ $term = get_term_by("name", $name,$tax); return !is_wp_error($term) ? $term->term_id : false; } Notice: Trying to get property of non-...
ali's user avatar
  • 45
1 vote
1 answer
43 views

Plugin Architecture Question: How to avoid using transients

I am creating an in-house plugin that will offer a filtering mechanism using AJAX for any post type depending on the configuration, which I have stored in a JSON. When the plugin is loaded, I need to ...
csaborio's user avatar
  • 112
0 votes
1 answer
208 views

get_option / wp_localize_script Not Working in OOP Plug In

Got this working the other day in a single-file php plugin which only consisted of functions. Now I am trying it out with the WordPress Plugin Boilerplate which is an OOP approach with a lot of ...
Brian Bruman's user avatar
0 votes
1 answer
33 views

Wordpress plugin blog creation

I'm trying to create a custom plugin for my website. class SoaneNews { function __construct(){ add_action( 'init', array($this,'pluginprefix_setup_post_type')); } function ...
Issac Surendar's user avatar
1 vote
2 answers
60 views

Most efficient way to use classes to create admin pages using Settings API

I've built a class which creates admin pages with the Settings API. I'm trying to optimize it to run only where I need it. Most of the examples and tutorials I've seen say to instantiate it from the ...
Robert Gillmer's user avatar
0 votes
0 answers
61 views

When developing WordPress plugin, is it a good idea to create my class object by hooking to existing class constructor?

I want to create my object when another object is made. Is it a good idea to create my object by hooking to existing class constructor? for example if the main class is class WordPress_Class { /** ...
Saeid's user avatar
  • 103
2 votes
1 answer
561 views

Override WP Class Private Function

I'm new to community, I think you experts can help me in this. I have plugin installed and i want to its overwrite one function which is in class <?php class ...
Naveen Guleria's user avatar
2 votes
1 answer
3k views

set_sale_price in WooCommerce [closed]

I need to set a WooCommerce sales price in a function. I'm using set_sale_price - but I don't think it is working. I'm trying it two different ways: Method one: update_post_meta( $theID, '...
WilliamAlexander's user avatar
1 vote
2 answers
600 views

OOP Plugin Development. Including external object

I am developing a plugin by using classes and object oriented programming. Within my plugin I have included another object as I need to use the functionality of this other object. I am instantiating ...
ivantxo's user avatar
  • 123
0 votes
0 answers
49 views

functions won't fire after I converted my code from procedural code to OOP

As stated in the title, I had written a plugin that was pulling a blog post from a blog and then created a new blog post with that same data in the blog where the plugin is installed. When I put ...
bsmith's user avatar
  • 1
1 vote
1 answer
1k views

Shortcode Inside Class Not Working

Working on my first WordPress plugin and using OOP. I'm trying to create a shortcode that works within a class and confused about how to set it up. With my current setup, the shortcode only prints ...
Amy's user avatar
  • 33
0 votes
1 answer
398 views

How pass args to wp_list_comments callback?

i need to pass an arg to function that i am specifying as callback for wp_list_comments public function ggowl_comment_lister($ggowl_id,$icon_html){ $args = array ( 'post_type' => '...
user avatar
0 votes
0 answers
53 views

Child theme, how to cut the functions.php file into several classes?

The functions.php file of my Child Theme is a mess... I'd like to use classes in a separate folder (like /inc) but I would like to keep a maximum of security. For now everything works as excepted, but ...
cap340's user avatar
  • 123
0 votes
1 answer
321 views

Custom Post Type works when registered in functions.php but not when registered in plugin

I am creating a plugin which registers a custom post type called 'news articles' see the class for this code below: <?php /** * This plugin class is used to register the necessary custom post ...
dan webb's user avatar
  • 101
0 votes
0 answers
48 views

Getting unexpected warnings from theme options code

Actually i have built my own class for registering theme options, and it works fine, but once i started to make some arrangements warnings started to show and i can't catch what wrong have i done. I ...
Makiomar's user avatar
  • 151
1 vote
1 answer
1k views

What is the proper method of using global $post?

I am using global $post multiple times in a class. These are my doubts Is that a bad practice? Can it result in slow websites? What's the proper way to use it inside a class class Test{ public ...
user avatar
0 votes
0 answers
36 views

Pass an argument into a function to extract from array

I feel like this should be possible. I have a function within my class which pulls a single row from my custom table: class Get_Data{ public static function get_data_single_db() { ...
Shaun21uk's user avatar

1
2 3 4 5 6