How to monetise wordpress plugin

I want to monetise a wordpress plugin that I am creating and I was wondering if I would be allowed to place adverts on the settings page? My plan is to release it on the wordpress plugin site.

Also, does anyone have any alternatives on monetising it? I considered codecanyon, but they do not seem to have many sales for plugins when I looked.

Go to Source
Author: Anon ymous

How do I check if a theme has a file single-cpt.php?

I’m creating a cpt plugin that will add ‘single-cpt.php’ in the theme directory.
The following code works but only if I put it in a functions.php (theme) folder.

// check if the file exists
$checkFile = locate_template('single-cpt.php');
if (!empty($checkFile)) {
    echo "Found!";
} else {
    echo "Not found";

How do I get the plugin check if the current theme has that single-cpt.php file ?

Go to Source
Author: Ash

How to change the Media Uploader screen from WordPress admin to normal browse screen for frontend users for featured image submission

I have a theme form in my frontend which takes the featured image from the user. But my problem is when the user clicks the upload button they are taken to the normal MEDIA UPLOADER screen which is normal for admin users. On top of that, the site visitors can also see the other media library images. I want to change this media uploader screen to just file browse screen. My site users are of “Authors” category. Please need help!

Go to Source
Author: Muhammad Aurangzeb Khan

Settings checkbox not triggering function

I have recently created this code as a plugin to store a setting in the WooCommerce general settings. The checkbox is meant to

// Check if WooCommerce is active
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {

    // Settings
    function hm_woo_disable_shop_settings( $settings ) {
        $settings[] = array(
            'title' => __( 'Disable Shop', 'wcds' ),
            'type' => 'title',
            'desc' => 'Check this box to disable all WooCommerce features',
            'id' => 'wcds_settings',

        // Checkbox
        $settings[] = array(
            'title'             => __( 'Disable', 'woocommerce' ),
            'desc'              => __( 'This has no affect to the database and will only limit frontend functions', 'wcds' ),
            'id'                => 'wcds_checkbox',
            'default'           => '',
            'type'              => 'checkbox',
            'desc_tip'          => true,
            'value'             => get_option('wcds_checkbox'),
            'checked'           => esc_attr( checked( 1, get_option('wcds_checkbox'), false ) )

        $settings[] = array( 'type' => 'sectionend', 'id' => 'wcds_settings' );
        return $settings;
    add_filter( 'woocommerce_general_settings','hm_woo_disable_shop_settings', 10, 2 );

    // Functions
    function woocommerce_disable_shop() {
        global $woocommerce;

        // Get the checkbox value from settings
        if( get_option( 'wcds_checkbox' ) === '1' ) {
            add_filter( 'woocommerce_is_purchasable', '__return_false');
    add_action( 'init', 'woocommerce_disable_shop' );

Go to Source
Author: Jesse

publish_{$post_type} hook works only for posts and not for custom post types or pages

I’m trying to send push notification when any of posts, custom post types or pages is published. I’m getting enabled post types from the plugin settings and adding action via foreach loop in my class __construct method. The problem is that it only works for posts and not for any of custom post types or pages. Here is my function and action:

foreach ((array)get_option('PushPostTypes') as $postType) {
    add_action("publish_{$postType}",  array($this, 'doNewPostPush'), 10, 2);

public function doNewPostPush($id, $post) {
    $pushData = array(
        'title' => $post->post_title,
        'body' => strip_tags($post->post_content),
        'data' => array(
            'url' => trailingslashit(get_permalink($id)),

    if (has_post_thumbnail($id)) {
        $pushData['image'] = get_the_post_thumbnail_url($id);

get_option('PushPostTypes') is an array of post types that user choose, for example: array('post', 'page', 'custom_post');

Any idea why it only works for post and not for pages or custom post types?

Go to Source
Author: Akaki Khujadze

Header Button Chance Polylang Elementor

Currently, I am making a Bilingual website, and I made a button on the header as well, and I want to make the button bilingual as well, but I don’t know how could I change its language because it is not part of the menu.
I use Polylang and Elementor.

enter image description here

Go to Source
Author: Anon

Custom post type specific item design

I have a custom post type (benefits). Which as post name (bronze, silver, gold, diamond). All are listed in the same page template page-benefits.php. I want to display all on the same page but want to specific design for Diamond.
how I can achieve this while remaining in the same loop and same page template.

Go to Source
Author: Sajjad Hussain

WordPress Plugin Development – get_option error

I am trying to put the option on selected with the built in function of wordpress called selected. I have tried to change the key from opt to different key names for every select field and it still didn’t work.

At the moment i am stuck, see my code below:

$taxonomy_args = array(
    'public'    =>  true,
    '_builtin'  =>  false

$taxonomy_names = get_taxonomies($taxonomy_args);

$select_field = get_option('select_field');

echo "<form id='example_details' method='post' action''>";
    foreach( $taxonomy_names as $taxonomy_name ) {
        echo "<div class='div_fields'>";
        $taxonomy_name_lc = strtolower($taxonomy_name);
        echo "<label for='${taxonomy_name_lc}_select_field'>${taxonomy_name}</label>";
            echo "<select class='example_form_select' name='details_select_field[opt]' id='${taxonomy_name_lc}_select_field'>";
                echo "<option></option>";
                $terms = get_terms( array( 
                    'hide_empty'    => false,
                    'taxonomy'      => $taxonomy_name
                ) );
                foreach ($terms as $term) {
                    echo "<option id='" . $term->name . "' value='" . $term->name . "' " . selected(isset($select_field['opt']), $term->name) . ">" . $term->name . "</option>";

            echo "</select>";
        echo "</div>";
    wp_nonce_field( $this->plugin, 'details_nonce' );
echo "</form>"; 

I did a var_dump on the $select_field variable but that one returns a boolean of false.

Go to Source
Author: Otto

wordpress: how to make custom url format for posts in this way

i want my posts urls be like this:
where iiii is a number that starts from 0001. for example first post url today will be: ~/202006070001/ the next will be ~/202006070002/ and so on. and the next day the iiii will reset to 0001 again and starts over.

i want to setup a mailroom service online for my company this way. thats the reason.

so, this is my problem, how can i do this?

Go to Source
Author: Nima Metana

How to get where an object first instantiated

I have built a theme options class so i can build as many option pages as i want, an i implement a singleton design pattern to fetch options only once, and i have WPML plugin installed so i am trying to make options multilingual using the available hook wpml_multilingual_options and every thing seems to be saved and also displayed correctly on frontend but unfortunately in the admin it keeps showing the none translated options, so i am guessing that the singleton object is called somehow before the init hook where the wpml_multilingual_options is hooked to. But i can’t find where exactly that singleton object is. can i track an object of the same singleton to find out the path of where the first instantiation occurs.

Go to Source
Author: Mohamed Omar