Firstly, to do this the register_metaboxes()
method needs to be static:
public static function register_metaboxes()
{
}
Then, for the callback you pass an array with the full class name including the namespace:
$args = array(
'register_meta_box_cb' => [ 'FrameWork\Helper\Metabox', 'register_metaboxes' ],
);
If, for whatever reason, register_metaboxes()
isn’t static (i.e. you’re using $this
) then passing the class name isn’t enough, you need to pass an instance of the class:
namespace FrameWork\CPT;
class CPT {
public function register_custom_post_type()
{
$meta_box_helper = new FrameWork\Helper\Metabox();
$args = [
'register_meta_box_cb' => [ $meta_box_helper, 'register_metaboxes' ],
];
register_post_type( 'plugin-cpt', $args );
}
}
Related Posts:
- How can I convert MP3 file to a Base64 encoded string? [closed]
- What is a sanity test/check
- What is an instance variable in Java?
- Discord music bot not working
- Python Math – TypeError: ‘NoneType’ object is not subscriptable
- did you specify the right host or port? error on Kubernetes
- How does Java’s PriorityQueue differ from a min-heap?
- What is a Memory Heap?
- 403 Forbidden vs 401 Unauthorized HTTP responses
- Advanced AREL or just Rails Query for has_many through search by association
- “If not” condition statement in python
- How can I sort a dictionary by key?
- What does ERR_SPDY_PROTOCOL_ERROR mean in nginx?
- What is a bitmask and a mask?
- C++ code file extension? What is the difference between .cc and .cpp
- How to remove origin from git repository
- How to convert .crt to .pem [duplicate]
- pagebreak in markdown while creating pdf
- Time Complexity of Prims Algorithm?
- Ping – Request timed out
- How do I remove version tracking from a project cloned from git?
- How do I split a string on a delimiter in Bash?
- Why does Wi-Fi have so much more bandwidth than Bluetooth?
- What’s the difference between & and && in MATLAB?
- azure error 502 – Web server received an invalid response while acting as a gateway or proxy server
- What is a Ray ID (Cloudflare)?
- How do I get a list of built-in data sets in R?
- java.text.ParseException: Unparseable date
- Difference between .o and .ko file
- R error: all arguments must have the same length
- spring @sqlgroup with multiple datasource
- What is the definition of a “disparity map”?
- Alternative to ui-grid(doesn’t support angular2/4)
- Tool for drawing parse trees?
- How do I install the OpenSSL libraries on Ubuntu?
- How can I specify a display?
- Clearing localStorage in javascript?
- Search all the occurrences of a string in the entire project in Android Studio
- “docker build” requires exactly 1 argument(s)
- declaring a priority_queue in c++ with a custom comparator
- How to resolve the error java.net.SocketException: Too many open files
- Using map in Haskell
- R dates “origin” must be supplied
- How to one hot encode several categorical variables in R
- cannot load such file — bundler/setup (LoadError)
- Downgrade npm to an older version
- Mongoose.js: remove collection or DB
- slideToggle JQuery right to left
- Valgrind Invalid free() / delete / delete[] / realloc() in C
- Exception in thread “main” java.lang.reflect.InvocationTargetException
- “webxml attribute is required” error in Maven
- How can I change the color of my prompt in zsh (different from normal text)?
- mkdir c++ function
- C’s printf and fprintf(stdout,) are not printing
- What’s the difference between SoftReference and WeakReference in Java?
- Identity matrix in Julia
- Letsencrypt renewal fails: Could not bind to IPv4 or IPv6.. Skipping
- reversing list in Lisp
- How to disable Windows Update Medic Service?
- Systrace for Windows
- Good way to encapsulate Integer.parseInt()
- TCP/IP packets and datagrams
- ArrayList of int array in java
- What are the differences between Mustache.js and Handlebars.js?
- Vim Opening File E325 Attention Error
- Terminating app due to uncaught exception ‘NSUnknownKeyException’
- add_action in namespace not working
- Rewrite the base-url for single posts
- How to parse wordpress options json
- Implementing namespaces in plugin template
- Displaying a message when plug-in is deactivated
- A post has a js redirection script. How to not redirect its category?
- Namespaces declared by a theme/plugin should start with the theme/plugin prefix. Found: “eustatos\test_plugin”
- Rendering javascript in render_callback php Code
- Access WP_REST_Server from within plugin namespace
- How to get a value from wp_dropdown_user?
- Customized Essay Writing Service
- Hiding class namespace from plugin’s extensions
- Reorganization of namespaces
- What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats?
- How to set environment variable in systemd service?
- Symlink not updating as expected when using an absolute with relative path
- How to include multiple domains in an spf TXT Record
- Physically locating the server
- Good tools that fit on a thumb drive [closed]
- How do you answer yes for yum install automatically
- All servers flooded by salt water, is it possible to recover data from multi-platter drives?
- How to check if I’m in screen session?
- How to zip/unzip files in Powershell?
- Cooling Server Closet – No A/C Is Possible
- Is it better practice to buy RAID disks individually vs. in bulk?
- What range of MAC addresses can I safely use for my virtual machines?
- What sysadmin things should every programmer know?
- Why do systems generally disable virtualization by default in BIOS settings?
- 10 servers to administer and I’m a history major [closed]
- Making `wget` not save the page
- How do I list all connected Salt Stack minions?
- How to get Apache2 to redirect to a subdirectory
- What does that mean: packages excluded due to repository priority protections
- How can I set a short timeout with the ping command?