Questions tagged [namespace]

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

0
votes
1answer
50 views

Access WP_REST_Server from within plugin namespace

I am new to OOP and developing plugins. I have developed a plugin using the Plugin-Boilerplate with namespace. I expanded the boilerplate to include a REST folder and class so I could create custom ...
0
votes
1answer
79 views

Override plugin class which has namespace

I would like to override this plugin class : class-config.php namespace um; if ( ! defined( 'ABSPATH' ) ) exit; if ( ! class_exists( 'um\Config' ) ) { /** * Class Config * * ...
0
votes
1answer
24 views

Problem with autoloader and namespaces

I'm writing a simple plugin with oop and using namespaces and autoloading. Here is my main file: add_action('plugins_loaded', array(My_Test_Plugin::get_instance(), 'plugin_setup')); class ...
0
votes
0answers
33 views

Hiding class namespace from plugin's extensions

I'm developing a plugin using this boilerplate and I designed it to be extensible. The boilerplate supports namespacing and uses it and namespaces are bind to folder structure. The extensible part is ...
0
votes
1answer
60 views

Update body class based on theme as well as a html attribute

I just started using wordpress. Now I'm trying to create a theme for a static web page I wrote. For that web page I'm using barbajs, which is why I have a html tag (in my case a section tag) with a ...
0
votes
1answer
107 views

wp_localize_script() and JavaScript namespaces

As you are aware, wp_localize_script() allows the creation of a JavaScript object from a PHP object. So, after running the code in the example below: wp_localize_script('my-script', 'var_name', $var)...
0
votes
1answer
1k views

REST route from a plugin not working if WordPress is installed in a subdirectory

This question is basically a copy from the trac ticket I created #42973. On the Theme Sniffer plugin I replaced admin-ajax.php with REST endpoints. So when you want to run a check against the theme ...
0
votes
1answer
258 views

Autoloader not finding classes from my plugin

I am trying to work with autoloader in my plugin. In the main file of my plugin I have use My_Plugin\Includes; require_once( plugin_dir_path( __FILE__ ) . 'includes/class-autoloader.php' ); $...
2
votes
2answers
3k views

add_action in namespace not working

I decided to namespace my plugin, and I got it all to work, except in my main plugin file. I added two actions in that plugin, before calling the init method of the plugin. <?php namespace ...
0
votes
0answers
730 views

Custom Rest API namespace and endpoints are responding with 404 & 503 errors

I am new to WordPress plugin development. I was developing a plugin for WordPress that would be used to create mobile apps for WordPress Bloggers. The whole source code of the plugin is at:- https://...
0
votes
1answer
355 views

worldpay class not working with namespace in WordPress

I am trying to create Worldpay gateway with help of Worldpay library and my own extending code. Here is my code which I tried and failed to work on. require_once('init.php'); use lib\Worldpay; if($...
1
vote
1answer
97 views

How to add in my plugin a third vendor Git project with composer.json

I need to use this Git project in my plugin. First I drop source code in a folder, and load it with require_once dirname(__FILE__) . '/vendor/Frozensheep/RightmoveADF/RightmoveADF.php'; But there ...
2
votes
2answers
216 views

How to use defined in class file with namespace

Here is my code. defined( 'ABSPATH' ) || exit; namespace JSR; class myClass{ ... } This is giving below error Global code should be enclosed in global namespace declaration Any idea how to fix ...
0
votes
1answer
42 views

Reorganization of namespaces

First of all thank You for Your time. I use autoload in my 2 plugins. They have to different namespaces but i want to build one main plugin with autoload for this two plugins. In future i am going to ...
1
vote
0answers
127 views

Why namespaces are rarely used in WordPress plugins?

This is currently my impression. Many WordPress plugins I used do not use namespaces. On few occasions, on this website, I saw namespaces are good and should be used. Are there any drawbacks using ...
1
vote
2answers
1k views

Change name of custom post type archive

I have a custom post type acme_reviews. I've namespaced it as suggested in tutorials to prevent future conflicts. But I want its archive page to simply be acme.com/reviews, not acme.com/acme_reviews. ...
3
votes
2answers
501 views

Implementing namespaces in plugin template

To get with the time and improve my coding practices, I'm starting to implementing namespaces in my own plugins moving forward since there are some advantages, such as eliminating ambiguity. I found ...