If that’s the entirety of plugin — you never create an object instance of your class. Class itself is merely a definition. Just like functions don’t do anything unless called, definition does nothing unless object of it is created.
Thus new My_Custom_Plugin();
.
Note the if you want to be a good citizen you should allow others access to that instance in some way, if they want to interact with your code for some purpose. Unfortunately WP has no established mechanisms for it and typical low effort solution is to simply store the instance in a global variable (with reasonably unique name).
Related Posts:
- Plugin Form Submission Best Practice
- PHP error with shortcode handler from a class
- Using a plugin class inside a template
- How to create a flexible abstraction for WP_Query?
- What is the correct way to build a widget using OOP
- How to make method from plugin available in theme?
- Using OOP plugin’s methods throughout the website
- Single Responsibility Principle and WP Classes
- How Can I Add a Filter to Class Instance Only?
- The ideal place for storing persistent PHP objects
- Plugin Architecture/Design Pattern – is better to use a private Observer/Mediator Pattern for plugin subclasses or WP add_action?
- Using a front controller in a WordPress plugin, any suggestions?
- set_sale_price in WooCommerce [closed]
- WordPress Ajax callback function from plugin – OOP
- How do you render_callback for register_block_type to a method in another class?
- How to Create database table when Plugin installed/activated, and delete database when Plugin deleted
- Registering and using actions which return results in a Plugin class
- Advice on plugin structure
- Applying OO patterns and principles to plugin development
- Creating a shortcode, but getting tied up with OOP and Classes?
- Plugin Architecture Question: How to avoid using transients
- What is the proper method of using global $post?
- Dynamically creating classes for Widget API
- WordPress class, using add_action to call member function does not work
- Remove an action by extending class and replacing it
- Using OOP inside a Plugin – Is it allowed?
- A question about add_action()
- WordPress plugin development OOP style
- How to call a function from a shortcode function in an oop plugin
- Bad request 400 using class based files
- functions won’t fire after I converted my code from procedural code to OOP
- Performing ajax request in wordpress
- Error when activating a custom plugin on production server
- OOP development and hooks
- How to set a public variable in someone else’s plugin class
- How to Maintain url on form submit
- How is construct function working even when variable is assigned null value?
- Object Oriented plugin, add action and variables
- How do I create Widget within plugin that uses its own class?
- How To Remove The Filter That Adds JetPack Related Content To Dom [closed]
- Method not receiving attributes from shortcode call, general OOP problems
- What’s the best method for emptying an option created with the Settings API?
- template_include (overriding default plugin templates via current theme)
- Using composer for dependency management in plugindevelopment
- What is nonce and how to use it with Ajax in WordPress? [duplicate]
- Update exisiting site to 3.5 release candidate
- Why does do_action pass a blank string as the first parameter if no $arg is set?
- add_filter and remove_filter added before and after wp_query
- How can I hook into existing WordPress Bulk actions?
- WordPress Media mime type filter problem 4.0
- creating elements/innerblocks via rangecontrol
- How to check if current static page is frontpage from admin plugin
- Earliest WP Hook to Safely and Reliably Redirect
- How can I display an error message after post has been saved?
- What method to use to call a REST API?
- Why my database table not created on activation?
- Resizing Images for a Gallery-Plugin?
- Which themes do you use to test compatibilities with your plugin [closed]
- How to debug a unit test for a WordPress plugin, which uses wordpress-test?
- Adding functions to hooks from within a class
- What filters to call to modify the output of the entire page?
- Tried in different ways but sidebar not working?
- How to Create a Simple Related Posts Plugin
- Help With Rewrite_Rules For a Custom Plug-In
- Theme Install using a Custom Repository
- How to add plugin version update option in plugin row action?
- Activate User in Code (BuddyPress+bbpress)
- wp_filesystem put_contents issue with owner/group
- error ‘The package could not be installed. No valid plugins were found.’
- Gutenberg table block with Bootstrap .table class
- Translate MCE button text/tooltip in custom plugin
- Can’t change the style of a submit input type? [closed]
- Odd map_meta_cap $args on post edit — sometimes integer, sometimes string
- How can I create a custom plugin that allows anonymous users to signup without registering?
- why update option is not working?
- WP: Search and replace in DB programmatically
- How to silent ‘Attempting a database schema change is discouraged.’?
- Get images / media attached to a page by page ID
- Plugin Development – Get Admin Url (Including cases where wp-admin is not used)
- Add code to template dynamically
- How Can I Add Code To A Preexisting Function Without Editing it
- Creating posts with links from a txt file
- Change the behaviour of a button
- escape html in jQuery for WordPress
- Progress bar in plugin within admin
- WordPress admin panel not working
- Redirection from a specific page for users logged in but not with membership
- Can’t get wpColorPicker to work in a widget
- WordPress Plugin Update Process
- Registration form Plugin… Email confirmation
- Can’t add images in wordpress to my page – button isn’t clickable
- Gutenberg and custom blocks messed up pagespeed score. What did I wrong?
- Gutenberg text field validation
- I don’t understand how symlinks in plugin work
- Build a dynamic block using the default attributes
- Show Admin Menu
- How to replace content of a block in and re-render on change?
- extending a core block doesn’t work inside the editor
- register_activation_hook doesn’t execute without add_action(‘init’,’some-function’)
- Getting similar posts by custom field value