Menu
  • HOME
  • TAGS

Usermeta in wordpress plugin won't save - development

wordpress,wordpress-plugin,wordpress-plugin-dev

I tried your code and value is saved correctly. Only one problem is there while displaying saved value. $user parameter needs to be passed in the function add_adslot_text. Eg: function add_adslot_text( $user )...

Slider misbehaving

css,wordpress,wordpress-plugin-dev

I've figured out somehow .shiftnav-wrap { margin-top: -1px; /* thank you very much @zgood, logotext / menu is not jiggling anymore :) */ } html { overflow-x: hidden; /* adding this line to hide the horizontal scrollbar that appear on slider closing phase */ } #scroll_totop { top: 850px; /*...

wordpress create two text field plugin save them in database [closed]

wordpress,wordpress-plugin,wordpress-theming,wordpress-plugin-dev

WordPress has API for you to do this. See what is prepared for you Example to copy...

Foreach not displaying the Results

php,mysql,wordpress,foreach,wordpress-plugin-dev

I'll put this in a comment but I don't have enough reputation. Do: var_dump($orders) and see what's inside. Maybe they are fetched as 'oi.order_id'....

data insert in wordpress cutom table not working?

php,mysql,wordpress,wordpress-theming,wordpress-plugin-dev

You have to declare globals: global $wpdb; // <= mandatory $wpdb->insert( 'wp_applicants', array('first_name' => $fname, 'last_name' => $lname, 'email' => $others), array('%s', '%s', '%s') ); ...

Wordpress change … from a plugin (without template edit)

wordpress,wordpress-plugin,wordpress-theming,title,wordpress-plugin-dev

create a plugin file and paste the code below... add_filter( 'wp_title', 'custom_title', 20 ); function custom_title( $title ) { return 'New title'; } ...

How to parse wp_get_themes parent data in wordpress

php,arrays,wordpress,object,wordpress-plugin-dev

following things will give you that object $theme= wp_get_theme('customizr-Child'); $them->parent() more info refer https://codex.wordpress.org/Class_Reference/WP_Theme...

How can i get price in woocommerce cart product title hook

wordpress,woocommerce,wordpress-plugin-dev

try this : add_filter( 'woocommerce_cart_item_name', 'cart_product_title', 20, 3); function cart_product_title( $title, $values, $cart_item_key ) { return $title . ' - ' . $values[ 'line_total' ] . '€'; } I don't know your version of woocommerce but woocommerce_in_cart_product_title is depreciated, it's why I use woocommerce_cart_item_name, so you should try both ;)...

W3 Total cache plugin breaking images on upload?

wordpress,wordpress-plugin,wordpress-plugin-dev

The issue was with php settings for apache. We reinstalled php and php related libraries we were using and it was resolved.

How to change custom admin menu?

wordpress,function,wordpress-plugin,wordpress-theming,wordpress-plugin-dev

can you plz try this code. <?php function edit_admin_menus() { global $menu, $submenu; $menu[24][0] = 'My Plugin'; // TO change admin parent menu $submenu['mylist'][0][0] = 'All Posts'; // To change child menu of "My Plugin" parent } add_action( 'admin_menu', 'edit_admin_menus' ); ?> Thanks....

How to add custom bulk actions in WordPress list tables?

php,wordpress,wordpress-plugin,wordpress-plugin-dev

There's a filter, but it's only useful to remove bulk actions. From this WPSE question, answer and comments, there's the following workaround: add a custom option to the dropdown with jQuery and hook into admin_action_$your-action to catch the submission. The hook admin_footer-$current_page is used to print our JavaScript on a...

Add custom CSS to shortcodes

wordpress,wordpress-plugin-dev

The summary is, when your plugin is loaded, you should register bootstrap : add_action( 'wp_enqueue_scripts', 'my_plugin_register_scripts' ); function my_plugin_register_scripts(){ wp_register_script('bootstrap','//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js',array('jquery'),'3.3.2',true); wp_register_style('bootstrap','//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css', array(), '3.3.2'); } Then, when your shortcode is called, you enqueue bootstrap : wp_enqueue_script('bootstrap');...

Why do I get “POST http://54.xx.xx.xx/wp-admin/admin-ajax.php 500 (Internal Server Error)” when using Wordpress+Ajax?

php,jquery,ajax,wordpress,wordpress-plugin-dev

your URL is wrong and should be: url: document.location.protocol+'//'+document.location.host+'/wp_admin/admin-ajax.php', ...

How can I add the custom text fields under own plugin of WordPress?

wordpress,wordpress-plugin,wordpress-plugin-dev

First of all you should create a admin menu page for the plugin options. use the below code in your plugin page. add_action('admin_menu', 'my_menu_pages'); function my_menu_pages(){ add_menu_page('My Page Title', 'My Menu Title', 'manage_options', 'my-menu', 'my_menu_output' ); } function my-menu(){ // code for displaying text areas for api key and url...

Check user permissions works in plugin but produce error in admin panel

php,wordpress,wordpress-plugin-dev

please try below approach <?php /* Plugin Name: Check gallery user Description: Check gallery user Version: 1.0 */ function cgu_init() { if ( isset( $_GET['cgu_check'] ) && 'check' === $_GET['cgu_check'] ) { $manage_options = 'no'; if ( is_user_logged_in() && current_user_can( 'manage_options' ) ) { $manage_options = 'yes'; } $perms =...

Wordpress Pre Fill content in Posts

php,wordpress,wordpress-plugin,wordpress-plugin-dev

This is what I ended up doing : in jQuery : function add_to_post(feed_id) { var title = $(document.getElementById('title_'+feed_id)).text(); var content = $(document.getElementById('summary_'+feed_id)).text(); var link = host+"/wp-admin/post-new.php"; var data = { 'post_title' : title, 'pre_content' : content, 'post_type' : 'post' }; $.extend({ redirectPost: function(location, args) { var form = ''; $.each(...

Why custom metabox value being added to the permalink

wordpress,wordpress-plugin,wordpress-theming,wordpress-plugin-dev,wordpress-loop

Not sure how or why, but WP_Query is affecting the post slug of newly created posts. It takes the last speaker and uses it as slug of the new event being added. One wonders why this is the most frequent Q&A at WordPress Developers: When should you use WP_Query vs...

Why do I get “POST http://54.xx.xx.xx/wp-admin/admin-ajax.php 500 (Internal Server Error)” when using Wordpress+Ajax?

php,jquery,ajax,wordpress,wordpress-plugin-dev

The error 500 is throwing because your server is not responding to your call. Did you tried with at start of the php file. error_reporting(E_ALL); ini_set("display_errors", 1); Use firebug so it will post you the call to server and response so you could see the error. If you are seeing...

WordPress plugin settings not saving and getting redirected to /wp-admin/options.php (which generates a 404) on submit

php,wordpress,wordpress-plugin-dev

If you are saving a large number of options, make sure you don't saturate the max_input_vars limit, that was introduced in PHP 5.3.9 to limit the number of accepted input variables - from the PHP docs: How many input variables may be accepted (limit is applied to $_GET, $_POST and...

Wordpress post to user relation ship

wordpress,wordpress-plugin,wordpress-theming,wordpress-plugin-dev,wordpress-loop

Install Post2post https://wordpress.org/plugins/posts-to-posts/ Then in your function.php write this code p2p_register_connection_type ( array( 'name' => 'releated_user', 'from' => 'story', 'to' => 'user' ) ); here story is your custom post type slug. related_user is just a connection name.You can name it as what you like. Then in your post type...

How to add user roles dropdown in registration and login woocommerce wordpress

wordpress,woocommerce,wordpress-plugin-dev,wordpress-loop

Try this : function ts_wp_dropdown_roles( $selected = '' ) { $p = ''; $r = ''; $editable_roles = array_reverse( ts_get_editable_roles() ); foreach ( $editable_roles as $role => $details ) { $name = translate_user_role($details['name'] ); if ( $selected == $role ) // preselect specified role $p = "\n\t<option selected='selected' value='" ....

How to write following queries in $wpdb

php,mysql,wordpress,wordpress-plugin-dev,wpdb

You can do like this for to show all tables like wp_ the same thing you have tried but it will give you as a object , parse them like following , it works me fine. $result = $wpdb->get_results( 'SHOW TABLES LIKE "wp_%"'); foreach($result as $index => $value) { foreach($value...

How to display custom post type in a submenu?

menu,wordpress-plugin-dev,custom-post-type

Probably i think you want to add a custom type post as sub-menu in WordPress dashboard. You can do. add_action( 'admin_menu', 'my_plugin_menu' ); function my_plugin_menu(){ add_menu_page('Page title', 'Top-level menu title', 'manage_options', 'my-top-level-handle', 'my_menu_function'); add_submenu_page( 'my-top-level-handle', 'Custom Post Type Admin', 'Articles', 'manage_options','edit.php?post_type=page_article'); } Don't forget to add below code while registering...

How to change image path in WordPress to subdomain in PHP

php,wordpress,wordpress-plugin-dev

No need using PHP, your just need to run this this SQL Query in phpmyadmin. UPDATE wp_posts SET post_content = REPLACE(post_content,'http://www.yourdomain.com/wp-content/uploads/','http://images.yourdomain.com/') For more information you can refer to this link. http://www.oxhow.com/host-images-wordpress-blog-subdomain-better-speed/...

Getting ID from get_posts within a loop in Wordpress

php,wordpress,wordpress-plugin-dev,wordpress-loop

It is because of the reason that you are not specifying the $args array parameters. Once, you specify them, you would get the desired results. Also, you code: get_the_title($jb_post); needs to be like this: get_the_title($jb_post->ID); For get_posts() complete reference , go to: https://codex.wordpress.org/Template_Tags/get_posts...

Styling of Custom Plugin in wordpress

wordpress,wordpress-plugin-dev

If you are trying to style backend (admin side) then you can use wp_enqueue_style . check below code . Add this code in your plugin page. define('PLUGIN_URL', plugins_url('', __FILE__ ) . '/'); add_action( 'admin_enqueue_scripts','my_plgin_style' ); function my_plgin_style(){ wp_enqueue_style('pluginstyle', PLUGIN_URL .'style.css'); } ...

How to execute filter code in wordpress page

wordpress,wordpress-plugin-dev,wordpress-loop,codex

This code will only work if put the code before the page loop. if(is_page(19) || is_page(461)) { remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); } get_template_part( 'loop', 'page' ); ?> ...

Change upload_dir folder at a certain cpt but cant change back

wordpress,upload,wordpress-plugin,wordpress-plugin-dev,custom-post-type

I found! this will only change the upload dir when upload in the "rsg_download" CPT add_filter( 'wp_handle_upload_prefilter', 'rsg_pre_upload' ); function rsg_pre_upload( $file ) { add_filter( 'upload_dir', 'rsg_custom_upload_dir' ); return $file; } function rsg_custom_upload_dir( $param ) { $id = $_REQUEST['post_id']; $parent = get_post( $id )->post_parent; if( "rsg_download" == get_post_type( $id )...

add a field to wordpress post

php,mysql,wordpress,wordpress-plugin-dev

First of all, you shouldn't modify the core table, as a lot of people already mentioned. You can do a select using join from both tables like that: $querystr = " SELECT $wpdb->posts.* FROM $wpdb->posts, $wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = 'tag' AND $wpdb->postmeta.meta_value = 'email' AND $wpdb->posts.post_status...

Process uploaded file in Wordpress plugin development

php,wordpress,wordpress-plugin,wordpress-plugin-dev

You should not leave the check for if (!empty($_POST) outside any function, it can go inside the admin_menu output. Also, the form actions should be left empty, so it posts to the same plugin page. The targeted enqueue can be done in a standard way too and note the shortcut...

WooCommerce programmatically add order for a specific user

woocommerce,wordpress-plugin-dev

You can do that with update_post_meta update_post_meta( $order->id, '_customer_user', $userid ); ...

add css class or id before a wordpress post/page

wordpress,wordpress-plugin,wordpress-theming,wordpress-plugin-dev,linkify

Checkout the Codex for body_class() and post_class(). If the theme supports it (and every well written theme should support it) you can add your own classes to the body or post. function my_plugin_class($classes) { if ( my_plugin_is_loaded() ) { $classes[] = 'my-plugin-class'; } return $classes; } add_filter('post_class', 'my_plugin_class'); // add...

How will i style wordpress custom menu page of plugins when developing a plugin?

php,wordpress,wordpress-plugin,wordpress-theming,wordpress-plugin-dev

try this function loadscript() { wp_enqueue_style('my-style', WP_CONTENT_URL . '/plugins/pluginname/css/mycss.css'); wp_enqueue_style('my-style', WP_CONTENT_URL . '/themes/themename/css/mycss.css'); } add_action('admin_enqueue_scripts','loadscript'); ...

Adding Booking Calendar to Wordpress.com Site

wordpress,google-calendar,wordpress-plugin-dev

Depending on which features you want, Google Calendar integration might suffice. It's one of the built-in plugins available on wordpress.com: https://en.support.wordpress.com/plugins/ Otherwise, if more custom features are needed, you might want to consider hosting elsewhere. Most shared hosting environments these days offer WordPress as an easy install, and there are...

WordPress Get All Posts With Specific Taxonomy

php,mysql,wordpress,wordpress-plugin-dev

I have resolved my issue once I found the Wordpress documentation for taxonomies. http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters The working code: $postArgs = array( 'posts_per_page' => 25, 'post_type' => 'property', 'tax_query' => array( array( 'taxonomy' => 'property-status', //Tax_Input 'field' => 'term_id', //Or Slug 'terms' => '48' //Term ID or Slug Name ) ) );...

Get Theme and Wordpress version details via API

wordpress,wordpress-theming,wordpress-plugin-dev

Use the $request parameter to pass the arguments, for example to get infos on Twentyfifteen theme: https://api.wordpress.org/themes/info/1.1/?action=theme_information&request[slug]=twentyfifteen Or to get the first 3 themes by the author Wordpress.org: https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[author]=wordpressdotorg&request[per_page]=3...

Undefined variable in a class when I have defined it

php,wordpress,wordpress-plugin,wordpress-theming,wordpress-plugin-dev

Like others have said, you need to be using $this->person because of the scope. Variables inside of functions only live inside those functions unless they are passed in and returned or passed in as a reference. To address your comment on the OP, you don't need to instantiate it in...

Warning: trim() expects parameter 1 to be string, array given in wp-includes/class-phpmailer.php on line 973

php,wordpress,wordpress-plugin-dev

I installed a package called "PostFix" which is responsible for sending emails from an Ubuntu server (which is the servers linux I use), and it solved the problem!

I need to pass a variable between files using PHP in Wordpress

php,wordpress,wordpress-plugin,wordpress-theming,wordpress-plugin-dev

Try adding a php injector and finish off with session if you prefer.

Best Wordpress Plugin to integrate external API´s

wordpress,wordpress-plugin,wordpress-plugin-dev

Usually there will be no plugin available for API. It's totally depend on what type of API you are using. Many API provides the document tutorial which will clearly give, how to pull data, edit, display on the page etc. Also, you have not specified the API which you are...

How to manually set a custom admin submenu selected?

wordpress,wordpress-plugin-dev

This has to be done with jQuery to add the proper classes to the admin menu. Use the following to print the script: # Grab the slug to print only in this screen $hook = add_submenu_page( null, # better than fake id "Edit Vendor", "Edit Vendor", 'manage_options', # IMPORTANT, don't...

How to tell if a script is being executed from a plugin, a theme or a child theme in WordPress?

php,wordpress,wordpress-plugin,wordpress-theming,wordpress-plugin-dev

This function will return a string indicating where it is called from. The possible return values are plugin, mu-plugin, child-theme, theme, or FALSE if it is not in a theme or plugin. When using this function, always pass __DIR__ as the parameter, example: where_am_i(__DIR__). /** * @param string $directory always...

How to avoid the product's limit for taxonomy in WooCommerce?

php,wordpress,wordpress-plugin,woocommerce,wordpress-plugin-dev

There are two options you could give a try: If you are filtering by category, you are probably using the ["product_category"] where the default per_page attribute is set to be 12. You can override that by specifying the per_page="16". Try to set a priority to your add_filter function in the...

Wordpress - Shortcode Ignoring External Divs

html,html5,wordpress,wordpress-theming,wordpress-plugin-dev

I managed to answer my own question so hope I can help others with the same problem: /*------------------------------------------------------------------- * Some Shortcodey Thingy *------------------------------------------------------------------*/ add_shortcode('thingy','thingy_shortcodes'); function thingy_shortcodes( $atts, $content = null ) { extract(shortcode_atts(array( 'category' => '0'),$atts)); ob_start(); <!--- use this to set the content you want to get AKA the...

wp_mail_from: different from address each time

wordpress,wordpress-plugin,wordpress-plugin-dev

wp_mail accepts "headers" http://codex.wordpress.org/Function_Reference/wp_mail#Using_.24headers_To_Set_.22From:.22.2C_.22Cc:.22_and_.22Bcc:.22_Parameters <?php $headers = 'From: My Name <[email protected]>' . "\r\n"; wp_mail('[email protected]', 'subject', 'message', $headers ); ?> ...

disable update for wordpress plugin named Dropbox Folder Share

wordpress,plugins,wordpress-plugin,wordpress-plugin-dev

The nicest way to do it would be to hook into 'site_transient_update_plugins'. function so_filter_plugin_updates( $value ) { unset( $value->response['dropbox-folder-share/dropbox-folder-share.php'] ); return $value; } add_filter( 'site_transient_update_plugins', 'so_filter_plugin_updates' ); A hacky way to do it would be to change the version number in the plugin to something ridiculously high, like 9999.999....

Is there a function that can get me the url of the directory of the file I'm working on? (Wordpress)

php,wordpress,wordpress-plugin-dev

In wordpress: <script type='text/javascript' src='<?php echo get_template_directory_uri(); ?>/js/scroll.js'></script> get_template_directory_uri() function return directory path of current active theme. EDIT: Try the follwoing function to get child theme directory. <script type='text/javascript' src='<?php echo get_stylesheet_directory_uri(); ?>/js/scroll.js'></script> ...

WordPress Redirect if logged into incorrect site with WPMU

php,wordpress,wordpress-plugin,wordpress-plugin-dev,wordpress-mu

The issue was that I was using Admin Menu Editor, which overrides the default behavior for WordPress, and therefore, "admin_page_access_denied" was never called. I added a do_action('admin_page_access_denied') to this plugin where it was denying access to a user. I hope this helps someone else not bang their head against a...

How can I select all categories in WordPress using a MySQL query?

php,mysql,wordpress,wordpress-plugin-dev

You can try the following: SELECT t.term_id AS id, t.name AS post_title, t.slug AS post_url FROM wp_terms t LEFT JOIN wp_term_taxonomy tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'category' ORDER BY name ...

woocommerce_add_order_item_meta hook sending only one argument; three expected

wordpress,woocommerce,wordpress-plugin-dev

Shame on me!I had not found necessary to add the last two arguments of the add_action() function. So the default number of argument being one, only one was passed to my callback. so the right code for the add_action() function is: add_action('woocommerce_add_order_item_meta', array($this, 'charlie_ajoute_un_order_item_meta'), 10, 3); Hope it may help...

Post curl data save twice using plugin hook function wordpress

wordpress,wordpress-plugin,wordpress-plugin-dev

Using this code i have fix the issue curl function on twice data post on post_save. More info this code <?php global $my_save_post_flag; // .. some stuff here .. if ($my_save_post_flag == 0) { // .. do the stuff only once i have add my curl code hear .. }...

What does internally hosted means

php,wordpress,wordpress-plugin,wordpress-theming,wordpress-plugin-dev

internally hosted means that you have your system running inside the company infrastructure. So it means that your client want to have wordpress installed on a server managed by the company.

Is there a difference between Wordpress Multisite (WPMU) and Wordpress, with respects to the hooks and the action reference (API)?

wordpress,wordpress-plugin-dev,wordpress-mu

'publish_post' is not attached to a single page (even on a non-Multisite install). The 'publish_post' hook is run by the WordPress core whenever a post is published. As long as this hook and the callback are part of an active theme or plugin (that exists across all multisite instances), they...

Add results into WordPress search results

php,wordpress,search,wordpress-plugin,wordpress-plugin-dev

You can use pre_get_posts to add/edit your search result without changing things is search template. To exclude pages To exclude pages in your search results. It is possible to create an action hook that limits the search results by showing only results from posts. The following example demonstrates how to...

How to add (Previous Post ID +1) for wordpress post title

php,wordpress,wordpress-plugin,wordpress-plugin-dev,wordpress-loop

$recent_posts = wp_get_recent_posts( array( 'numberposts' => '1', 'post_type' => 'yourcustopmposttype' ) ); $last_id = $recent_posts[0]['ID']+1; try this code please. You forgot to add post_type in your code.. that's why you are not getting result....

How to redirect a user with specific “ROLE” to a specific page after login in Wordpress [closed]

php,wordpress,wordpress-plugin,wordpress-plugin-dev

Try this : function rohil_login_redirect_based_on_roles($user_login, $user) { if($user->roles[0] === 'student_role'){ exit( wp_redirect('Your page link goes here') ); } } add_action( 'wp_login', 'rohil_login_redirect_based_on_roles', 10, 2); Explanation If you look at the codex, you will find that wp_login provides two parameter: 1) $user_login which will return a string and 2) $user will...

Wordpress custom post action hook

php,wordpress,wordpress-plugin,wordpress-plugin-dev,custom-post-type

Not sure if there is just one action but here are the various actions: save_post (create or update) wp_delete_post (deleted) wp_trash_post (trashed) so you can do something like this: function my_callback_function() { if($post->post_type = 'job') { //do something here } } all_actions = array('save_post','wp_delete_post','wp_trash_post'); foreach ($all_actions as $current_action) { add_action($current_action,...

Correct Way to Use AJAX to Update Wordpress Database

jquery,wordpress,wordpress-plugin-dev

That's not the way to do an AJAX call in WordPress. You're currently doing a direct AJAX call to the _process.php file. The call will work, but it's not loaded within the WordPress scope. There are 2 solutions: 1) Include wp-load.php inside your _process.php file, or: 2) (the best option)...

Add Button on Custom Plugin in WordPress

php,wordpress,wordpress-plugin-dev

You can use the $_column_headers extended Property this property is assigned automatically, must manually define it in their prepare_items() or __construct() methods. like, function prepare_items(){ $columns = array( 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text 'col_id' => 'ID', 'col_name' => 'Name', 'col_url' => 'URL', 'col_description' =>...

How Categories Images plugin maps images with term_id?

wordpress,wordpress-plugin,wordpress-plugin-dev

They are storing in the wp_post table, for Example if option_name column has z_taxonomy_image_19 in this 19 is term_id and z_taxonomy_image_ is for reference and option has url of that image

Fatal error: Call to undefined function is_user_logged_in()

wordpress,error-handling,wordpress-plugin,wordpress-plugin-dev

The problem is that is_user_logged_in is a pluggable function, and is therefore loaded after this plugin logic is called. The solution is to make sure that you don't call this too early. This can be done by wrapping this logic in a function and calling it from 'init' function rizwan_insert_coupons()...

save_post hook on curl responce error message display on Current post on like update message

wordpress,wordpress-plugin,wordpress-plugin-dev

public function __construct() { add_action('save_post', array(&$this, 'save_socipost')); //add filter on construct add_filter('post_updated_messages', array(&$this,'socipilot_updated_messages')); } public function socipilot_updated_messages($messages){ session_start(); //difine your message hear $messages['post'][11] = sprintf( __($_SESSION['soci_error'])); return $messages; } public function save_socipost($post_id) { global $post; global $socipost_save_post_flag; //function data //my fix code for message hear if($error_id==0...

Wordpress submenu_page variable

php,wordpress,admin,wordpress-plugin-dev

If I understand correctly you need to pass GET parameters to your plugin or theme. If so you can pass variables to your page in exactly the same way as you did in you standalone page: <a href='" . admin_url('admin.php?page=dnh_facturen_bekijk&myvar=myval') . "' target='_blank'> Bekijk </a></td>"; When you load the plugin...

Why do I get the error: “500 Internal Server Error” when passing parameters using Ajax on Wordpress?

php,jquery,ajax,wordpress,wordpress-plugin-dev

Wordpress doesn't like you directly posting to a php file within a theme. What you should be doing is post to / (or any template/path you would like to post to, say "contact") and place the form handling code in your theme files. I'd suggest putting your code in functions.php,...

How to set beforeSend option in wordpress ajax methods

php,jquery,ajax,wordpress,wordpress-plugin-dev

$.post() is just a shorthand method for $.ajax, as are $.get(),load() and $.getJSON() The shorthand methods already include some of the options within $.ajax() and are simply convenience wrappers so you don't have to apply many settings to use them. If the shorthand methods don't expose enough options for you...

How to remove the option to publish posts in the past with time stamp in wordpress?

wordpress,wordpress-plugin-dev,wordpress-filter

http://codex.wordpress.org/Plugin_API/Action_Reference/save_post is what you need. add_action('save_post', 'stop_publishing', 20); function stop_publishing($post_id) { $post = get_post($post_id); $post_date = $post->post_date; $current_date = date("Y-m-d"); //do your math of date calculation //user has set a date in the past, I am using an imaginary variable date_is_not_valid if ( $date_is_not_valid ) { $message = '<p>Please enter...

Permission error while developing Wordpress plugin

php,wordpress,wordpress-plugin,wordpress-plugin-dev

The fourth parameter in add_menu_page is the menu slug of string type use anything unique you want, and the first parameter of add_submenu_page is the parent slug and that is what you entered for add_menu_page menu slug add_menu_page( 'sms_menu_page', 'SMS Demo','manage_options', 'smsmenu','sms_plugin',plugins_url( '/Images/logo.png', __FILE__ ) ); add_submenu_page( 'smsmenu', 'AdminPanel','Admin', 'manage_options',...

How To Create a Plugin at Backend in Wordpress

wordpress,wordpress-plugin-dev

You can use add_menu_page() function for adding new menu in the backend(admin). add_action('admin_menu', 'my_menu_pages'); function my_menu_pages(){ add_menu_page('My Page Title', 'My Menu Title', 'manage_options', 'my-menu', 'my_menu_output' ); } function my-menu(){ // Your code /// } ...

mysql result to array to write to csv file?

php,mysql,wordpress,csv,wordpress-plugin-dev

The error message is telling you what is wrong. fputcsv() expects parameter 2 to be array And from your own admission (emphasis mine) If I var_dump($line) I get string(2) "37" each string and its the correct value Why not try this? You're building an array already. foreach( $catresults as $catresult...

What's a cleaner way to output HTML from a Wordpress plugin?

php,wordpress,wordpress-plugin,wordpress-plugin-dev

You could just use a single string with concatenations... $form = new \AdamWathan\Form\FormBuilder; $html = $form->open()->action('/apply')->class('bb-loan-form') . '<div class="bb-form-field"> <h2>Loan Application Number</h2>' . $form->text('loan_app_number')->id('loan-app-number') . $form->submit('Continue Loan') . '</div>' . $form->close(); return $html; It at least keeps the HTML aligned. I also don't really see an issue with Heredoc, as...

Wordpress - Widget Paramaters

php,wordpress,wordpress-plugin-dev

You're currently passing in an array of strings such as "$data->Title" when you should be passing the data contained within $data->Title. Change your widget call to this: the_widget( 'soc_latestwork','title='.$data->Title.'&subtitle='.$data->SubTitle.'&image_src='.$data->ImageSrc.'&image_url='.$data->ImageUrl, array('before_widget' => '', 'after_widget' => '')); ...

Custom page / message after installation of wordpress plugins

wordpress,wordpress-plugin,wordpress-plugin-dev

The register_activation_hook function registers a plugin function to be run when the plugin is activated. register_activation_hook(__FILE__, 'redirect_to_instruction_page'); function redirect_to_instruction_page(){ wp_redirect( admin_url( 'admin.php?page=instructions' ) ); exit; } ...

Why wp_mail() function returns 'false'?

php,ajax,wordpress,wordpress-plugin-dev

I installed a package called "PostFix" which is responsible for sending emails from an Ubuntu server (which is the servers Linux I use), and it solved the problem!

WordPress template_include filter not working properly

php,wordpress,redirect,wordpress-plugin-dev

Ok i done by my own. I delete all above code and write this code. It works perfectly for me Code: function template_chooser($template){ global $wp_query; $plugindir = dirname(__FILE__); $post_type = get_query_var('post_type'); if( $post_type == 'product' ){ return $plugindir . '/themefiles/single-product.php'; } if (is_tax('prodcategories')) { return $plugindir . '/themefiles/taxonomy-prodcategories.php'; } return...

How to work WordPress functions and database [closed]

php,wordpress,wordpress-theming,wordpress-plugin-dev,wordpress-loop

Well WordPress is basically just PHP, but with a bunch of functions, classes, methods, and hooks already defined. It works using regular methods to connect to and query a MySQL database. The Codex is the best place to learn about the functions etc. But you can of course actually look...

$wpdb->prepare is not working like mysql_real_escape_string

php,mysql,wordpress,wordpress-plugin-dev,wpdb

From what i'm seeing is that you are trying to sanitize a Result and not an SQL query. Therefor this will return false by default since wpdb->prepare() checks for a string with sprintf/vsprintf format pattern. https://developer.wordpress.org/reference/classes/wpdb/prepare/ And from what the variable contains you might want to check something more related...

Wordpress Add my plugin admin menu to my admin new role

wordpress,wordpress-plugin,wordpress-plugin-dev

Add capability for you new role and use this capability in add_menu_page. you can use this referral link...