Tag Info

New answers tagged

2

Parse action: function angular_ajax_params_to_post() { $is_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX ); if($is_ajax){ $params = json_decode(file_get_contents('php://input'), true); foreach ($params as $param_key => $param_val) { $_POST[ $param_key ] = $param_val; } } } add_action( ...


0

With the help of Marcin Pietrzak, I got the answer // "select * from wp_options where option_name = 'wpcf-fields'"; $custom_fields = ( get_post_custom($post_id)); $querystr = "select * from wp_options where option_name = 'wpcf-fields'"; $pageposts = $wpdb->get_results($querystr, OBJECT); if(isset($pageposts) and isset($pageposts[0])): $value = ...


0

In order to change upload size limit two options have to be changed in php.ini configuration file - upload_max_filesize and post_max_size. These options cannot be changed at runtime so you will need to have access to php.ini in order to modify them. Example: upload_max_filesize = 20M post_max_size = 22M


1

This is an issue with the creation of the nonce. wp_create_nonce( plugin_basename(__FILE__) ) . '/seo_fields.php" /> should probably be wp_create_nonce( plugin_basename(__FILE__) . '/seo_fields.php' ) . '" /> because otherwise !wp_verify_nonce($_POST['clinicalmeta_noncename'], plugin_basename(__FILE__).'/seo_fields.php') would not check for ...


1

Placing this answer for those people who're trying to fix the same issue. It's important where add_action('wp_ajax_setAsyncCheckProduct', [$this, 'setAsyncCheckProduct']); resides. In my case the issue was finally fixed moving a similar line to the main plugin file, where all concrete classes are included and initialised. Of course the line had to be ...


3

For do this you need to save in the db a value for remember that the alert was already showed. Else you can try to llok on that https://codex.wordpress.org/Function_Reference/register_activation_hook. With this you can execute an hook only on the activate action of the plugin.


0

How about having the location of the CSS file set as an option for the plugin in the admin area? The default setting would be your default stylesheet. The option would allow this to be changed to another specific stylesheet by the user, or removed entirely. If this option exists, your plugin enqueues the stylesheet. This allows the user to: replace ...


2

Here is the fixed and modified code which was having the nonce action issue. <?php /* Plugin Name: Test Plugin Plugin URI: Test Description: Test Author: Test Version: 007 Author URI: */ // add all post types $clinical_post_types = array(); $post_types = get_post_types(); foreach ( $post_types as $post_type ) { $clinical_post_types[] = ...


1

By passing the _builtin argument to get_post_types(), only WordPress default post types will be returned. Instead, just pass public as an arguement, Here's an example of output on a development site with WooCommerce activated: var_dump(get_post_types(['public' => true])); //result array(4) { ["post"]=> string(4) "post" ["page"]=> ...


0

My first response when I hear "custom tables" is - are you absolutely certain you need custom tables rather than using custom post types, post meta data, and custom taxonomies? Far fewer wheels to reinvent by going that route. That said, to integrate data into any theme, a couple of options are to either create a Shortcode to inject your data into the ...


1

Here is a quick and dirty plugin that shows you how to achieve this (adapt this example to your own architecture and needs): <?php /* Plugin Name: Custom rewrite rule test */ add_action( 'plugins_loaded', array(Registration::get_instance(), 'setup') ); class Registration { protected static $instance = NULL; public function ...


0

Create a new plugin with the following code: class Facebook_Peeker { private static $facebook_bots = [ 'facebookexternalhit/1.1 (+https://www.facebook.com/externalhit_uatext.php)', 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)' ]; private $original_posts; public function ...


1

Turns out you have to have a <p> tag in the div to prevent that.


1

Technically speaking, Woocommerce products are just another WordPress post object with a customized post type (which is product in this case). If you take a look at the create_product function inside class-wc-api-products.php, you'll see this line: // Attempts to create the new product $id = wp_insert_post( $new_product, true ); So the API ends up using ...


1

You will create a page template whose file name is custompage-template.php here I suppose put in in your plugin dir/views/ folder. Whenever the page whose title is Your Page Name is visited, the site will render your custom template add_filter( 'page_template', 'fw_reserve_page_template' ); function fw_reserve_page_template( $page_template ) { if ( ...


0

You can insert as many variables as you want (%digit, %string ...) global $wpdb; $zz = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = '%s' WHERE post_id = '%d' OR WHERE post_id = '%d' ", $value, $id_1, $id_2 ) ); var_dump($zz); exit;


0

I had a similar issue and was able to resolve the improper menu behavior by using the parent_file filter. $parent_file is set in the /wp-admin/edit-tags.php file, but it needs to be altered based on your use case. add_filter('parent_file', 'filter_subscriber_menu'); function filter_subscriber_menu($file) { $screen = get_current_screen(); if ...


0

To check if product already exists, you need to fire query in database with product title as shown below : global $wpdb; $result = $wpdb->get_row("SELECT ID FROM wp_posts WHERE post_title = 'title' && post_status = 'publish' && post_type = 'product'"); if(empty($result)){ // product doesn't exists } else{ // product already ...


-1

In your case is not possible SQL injection attack. Your code don't need additional protection because don't use user input like: post, get, request, cookie. http://php.net/manual/en/security.database.sql-injection.php Don't use complicated function when are not necessary to save server resources.


0

Using the following modifications and adding in die() stopped the script and output whatever the variables value was at that time. Thanks to @toscho function cf7pp_after_send_mail( $contact_form ) { global $postid; $submission = WPCF7_Submission::get_instance(); if ( $submission ) { $posted_data = $submission->get_posted_data(); ...


0

GitHub Plugins With Automatic Upgrades is a highly detailed article I'm referring to related to a project I have which will require automatic (one button) upgrades for both GitHub hosted + Website hosted plugins. The idea is very simple. During the upgrade process, your code modifies the WordPress internal data structures to look enough like the WP ...


2

The short answer to your question is yes; however, the methods to do this are a little bit hacky and generally I would recommend against all of them unless absolutely necessary. Since pluggable functions actually replace the stock function by way of function_exists() whichever plugin that "plugs" the function first will win. What you want to do is ensure ...


0

i am logically very much clear with this kings of function because i have made such function in woocommerce the operation is all about to integrate the big post shipping rates. but in your case you need to add_fee() function in woocommerce. the first things you need to get the market charge and add into your cost. i hope below code will helps. function ...


0

jQuery(document).ready(function($) { var calendar = jQuery('#calendar').fullCalendar({ editable: true, header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' } }); }); Now i am not gett


0

The following code worked. According to the comment by Milo, I have been doing it wrong by using the option name. So instead I used each keys from the option and used the array to pass the defaults. Thanks milo! :_ register_activation_hook( __FILE__, 'twmm_activate'); //activate plugin options open activation of plugin register_deactivation_hook(__FILE__, ...


0

Yes, This is the correct way. Many of us use styles to alter the look of our website, and scripts to enhance functionality. It is important to note however, that the way you add these scripts to WordPress is just as important as the content of these files. Instead of plopping them into the header or footer file we need to use WordPress enqueue ...


0

I saw unstyled content in a child theme when I mistakenly changed the theme name in 'style.css' while it was still selected as the active theme in Wordpress. So it wasn't picking up anything from the theme or the parent. Maybe check the names and filepaths match up?


1

You are misspelling value to vaule: echo "<option vaule='editor'". selected( $options['twmm_permission_lvl'], 'editor')."> Editor </option>";


0

The code in the original question was on the right track. The code below was taken from the linked tutorial. Basically all I had to do was create a template file in my plugin (I just copied some code from single.php from my main theme to use as a guide into: dirname( __FILE__ ) . '/staff-template.php' Then when the template_redirect is run it displays ...


3

Give it a try like so: File: oowp/bootstrap.php <?php /* Plugin name: OOWP */ require_once( 'autoload.php' ); use oowp\objects\Custom_Objects; new Custom_Objects;


1

update_option('acp_cf_settings' , array('acp_cf_status'=>$resp['status'])); update_option('acp_cf_settings' , array('acp_cf_log'=>$resp['log'])); You are overwriting the setting. After the second update_option call there is no acp_cf_status key anymore for the array variable, just the acp_cf_log. Just to be clear, you would need something like this: ...


0

I am afraid there is no such plugin with the exact functionality you are looking for but you can try one of these plugins link to meet your requirements.


0

You are already echoing the data. Just use the_content(): echo '<div class="category-description"><p>',the_content(),'</p></div>'; Please note: those are commas not periods. echo will accept multiple parameters separated by commas and you will not see the odd results you get if you try to concatenate. The above is functionally the ...


0

Ok, maybe I asked it too soon ... took a look at it again and gave myself a slap for being so stupid. The widget-config.php is set to update when the page loads so every time it loaded the page it updated the 'example_number' option all you need to do is add if(isset($_POST['submit'])) to it.


2

get_the_content do not apply the_content filter. You have to apply it after receiving contents like following <?php apply_filters('the_content',get_the_content( $more_link_text, $stripteaser, $more_file )) ?> It is also detailed at the bottom of codex page


0

This code display all posts of all categories of genre taxonomy for custom post type book. Now, For different custom post type (author, product ) you have to change Custom Post Type Name inside $arg of WP_Query(). You will get term link using get_term_link($catterm) function or you can use also get_the_term_list(). $args = array( 'number' ...


0

Good news, I figured out a way to accomplish this. Here is my solution. Taking my example above, I will walk you through what I did to get example.com/book/genre/horror to point to custom post type book, taxonomy genre and category horror. Pretty permalinks should be enabled. Go to Settings > Permalinks to enable it. Otherwise there is no point of doing ...


0

TL;DR: After the draft_to_publish hook is executed, the page is redirected, so you won't see the echoed output. Ref: http://wordpress.stackexchange.com/a/94011/71131 I think the problem is that the draft_to_publish action saves the post, which will call a redirect request to the browser, which loads the edit page from scratch again. Then whatever whatever ...


0

That looks like it is an error due to TinyMCE (editorremov I believe) not being loaded yet. Either hook to the admin_footer action instead of admin_head (interestingly you have declared the in_footer option as true and it is still not working) or declare the editorremov dependency when enqueuing your script: wp_enqueue_script( 'features', plugin_dir_url( ...


0

Use the admin-post action hook to intercept POST requests and process forms. The admin_url() function can be used to output the correct URL, and use wp_redirect() to redirect back to your plugin page after processing. And do yourself and your users a favor- don't reinvent wheels and add tables when the native tables and API can be used.


-1

Try to simply use ob in your function like so: add_action( 'draft_to_publish', 'my_hooked_function', 10, 10 ); function my_hooked_function( $post ) { ob_start(); echo '<script>console.log("some stuff to output to the developer console, via html page");</script>'; $output = ob_get_contents(); // Put ob content in a variable ...


4

Wait for the action plugins_loaded before you create the class instance. The pluggable functions are loaded at this time. From wp-settings.php: /** * Fires once activated plugins have loaded. * * Pluggable functions are also available at this point in the loading order. * * @since 1.5.0 */ do_action( 'plugins_loaded' ); I would even wait for ...


1

The simplest and quickest solution would be to use the add_rewrite_endpoint function. <?php add_rewrite_endpoint( $name, $places ); ?> So in your case it would be something like this: add_rewrite_endpoint( 'user', EP_PERMALINK | EP_PAGES ); An user URL would look like this: http://www.example.com/my-page/user/john To access the variable: ...


0

You are missing 2 parameters in your function report_spam. Also the priority should not be 1. Try the code below. add_action('transition_comment_status', 'report_spam', 10, 3); function report_spam($new_status, $old_status, $comment){ if($new_status == 'spam'){ var_dump($comment->comment_author_IP); die; } } I've set die so ...


0

If you don't want to use the Dashboard Widgets API you can use this code snippet that I have quickly concocted as a starting point: function dashboard_daily_post_metabox() { add_meta_box( 'wt_id', 'Daily Post', 'dashboard_daily_post_process', 'dashboard', 'normal', 'high' ); } add_action( 'wp_dashboard_setup', 'dashboard_daily_post_metabox' ); ...


0

You should run your register_activation_hook after creating object. class Notification { function jal_install() { global $wpdb; global $jal_db_version; $table_name = $wpdb->prefix . 'fnotice'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE ...


2

You have misspelled the action hook name. This: add_action( 'after-setup_theme', 'ja_theme_setup' ); Should be: add_action( 'after_setup_theme', 'ja_theme_setup' ); The full code: add_action( 'after_setup_theme', 'ja_theme_setup' ); function ja_theme_setup() { add_theme_support( 'post-thumbnails'); }


-1

You need to go your wp-admin/post/ top right corner show "screen Options" click on this and expand screen-option then click on Featured Image check box Hope this help you..


-1

Your code should work , but as it is not working the try the following things add_theme_support( 'post-thumbnails'); Just put this code in functions.php , not within a function . Just put this code on the top of your functions.php file . If it is not working then try this plugin Drag & Drop Featured Image


0

After trying everything, this worked for me: global $allowedposttags; $allowedposttags['div'] = array('align' => array (), 'class' => array (), 'id' => array (), 'dir' => array (), 'lang' => array(), 'style' => array (), 'xml:lang' => array() ); $allowedposttags['iframe'] = array('src' => array () ); ...



Top 50 recent answers are included