Articles of plugin development

custom plugin with upload files does not work

I an creating a custom plugin that used shortcodes.. then it will have a feature that will upload files and stores it in wp-content/uploads/ directory.. but it seems I got an error.. Warning: move_uploaded_file(http://mysitecom/wp-content/uploads/myfiles/1991117- DriverLiscence.jpg): failed to open stream: HTTP wrapper does not support writeable connections in /home/user/public_html/mysite/wp-content/plugins/myplugin/functions.php on line 1266 Warning: move_uploaded_file(): Unable to […]

Function/Class to list categories with checkboxes

I want a list like in the pictue; witch is here – Posts->New->Select Categories At the moment i have this echo ‘<select name=”pn-cats[]” size=”8″ style=”width: 100%” multiple>’; $args = array( ‘type’ => ‘post’, ‘child_of’ => 0, ‘parent’ => ”, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => 0, ‘hierarchical’ => 1, ‘exclude’ => ”, ‘include’ […]

Unable to access custom plugin backend

So, I just created a new plugin and i’ve added capabilities, a new role, linked them all together, etc.. etc.. but for some reason I’m unable to access my own backend. Error message is the generic You do not have sufficient permissions to access this page. Code to create the Menu on the backend add_menu_page( […]

How to add category and subcategory in WordPress custom code?

I create custom plugin for import categories. now i have categories array from api.but when import categories into my wordpress woo commerce means not working. My code is given below. public function sample_insert_category() { if(!term_exists(‘sample-category’)) { wp_insert_term( ‘Sample Category’, ‘category’, array( ‘description’ => ‘This is an sample category.’, ‘slug’ => ‘sample-category’ ) ); } } […]

WordPress plugin: efficient way to store large data

I have excel file with 1000+ records. Basically it has zipcode and corresponding email addresses. I need to create a custom wordpress plugin which queries this data and sends the mail. It would be nice if I can show the data in admin area of the WordPress. Please suggest me Which is best way to […]

How to Show Author image and url in WordPress plugin directory?

I just added a plugin(My-auction-creator) in to WordPress Plugin directory. But sadly when I open the plugin URL the author image is not showing nor the url is linked. So anyone can help me to show my image and url there? Below the screenshot: Here is the link : https://wordpress.org/plugins/my-auction-creator/

why update option is not working?

I have following code which is not working: var_dump($resp[‘status’]); //output: ‘status’ => string ‘yes’ (length=3) update_option(‘acp_cf_settings’ , array(‘acp_cf_status’=>$resp[‘status’])); update_option(‘acp_cf_settings’ , array(‘acp_cf_log’=>$resp[‘log’])); $options = get_option(‘acp_cf_settings’); $resp[‘status’] = $options[‘acp_cf_status’]; var_dump($resp[‘status’]); //output: ‘status’ => null Here $resp is an array and ‘acp_cf_log’ setting is updated but ‘acp_cf_status’ is not updating, so where I am doing mistake ? thanks

A function that will remove HTML <div> and </div> tags from a string?

I need a function that I can use that will remove <div> and </div> tags from a string. I have tried esc_attr(), and even wp_strip_all_tags() — none of them work. They all leave the <div> and </div> tags in the string – which causes certain social-media buttons to turn out in ways that really do […]

Copied files from plugin to theme not working

I am working on a plugin. In plugin folder, there is a folder ‘template’ from where i copied the files and paste into ‘my_folder’ in active theme. They move perfectly. Now when i editing files from the theme they did not edited, but when i edit files from plugin folder, they edited. I just want […]

How to add filter for wordpress plugin?

I have a really newbie question, but I’m really new to WordPress development. In the plugin that I’m using is using this filter. if ( true === apply_filters( ‘some_custom_filter’, false ) ) { return $something; } Now I’d like to add_filter so it will return true how do I achieve that? This is what I’m […]