Tag Info

New answers tagged

0

Thanks for all the help, unfortunately I don't have enough time to figure out what isn't working (customer tapping feet). All suggestions did'nt work, so I'm going the "normal" (ugly) way of reading out $_POST. Thanks for the efford.


0

Change your wp_localize_script-Call to the right Action: wp_localize_script( 'addItemToNav', 'menuItems', array( // URL to wp-admin/admin-ajax.php to process the request 'ajaxurl' => admin_url( 'admin-ajax.php' ), // generate a nonce with a unique ID "myajax-post-comment-nonce" 'postCommentNonce' => wp_create_nonce( ...


0

Your AJAX Requests requires an JSON to be returned. But I think your function doesn't return valid JSON. Haven't tested it, but this function should work: function update_nav_items() { // Testing stuff $response = json_encode( array( 'response' => 'success', 'html' => 'some value' ) ); // first JSON encode ob_clean(); ...


0

Problem is that your server is executing different PHP protocol from the the one used by WordPress, i don't know how that happens. You can check PHP protocol you are running by looking into phpinfo() for a line SERVER API. Or if you have cPanel on your hosting, you can see How to enable suPHP in cPanel. You do a workaround with FTP details in wp-config.php ...


0

"Could CloudFlare have anything to do with it?" CloudFlare doesn't proxy ftp traffic & this is really generally going to be something to take up with your hosting provider.


1

This can be done by having the display: none; only on the .logged-in selector. Like this... .logged-in .hide-item-not-login { display: none; } You might want to change that .hide-item-not-login to a more accurate .hide-item-login or something to make it more clear for this changed use case. Though it makes no difference to the functionality of it.


1

Can't you change CSS rules? .hide-item-not-login{ display: block !important; } .logged-in .hide-item-not-login{ display: none !important; } EDIT To add login/logout menu item, you will need to add one more class to logout menu item. Let's say you added class .logout-link to logout menu item. Then you can add css like this. .hide-item-not-login{ ...


1

You could also remove all the breaks in your code. For example of: Instead of: function() doSomething() { //code goes here } Do something like this: function() doSomething() {//code goes here} Its annoying but it will allow you to still use WordPress' text editor.


4

The post editor is really not meant for inserting functional code like JavaScript into the page. Anything you put through the post editor will get run through wpautop() before output, which is what adds the paragraph tags -- even if you enter it via the Text mode. I'd suggest outputting your JavaScript via a hook on the page instead of via the post editor. ...


0

The correct way to do this these days is to include your schema as a file in the plugin source and use the inbuilt WordPress function dbDelta() to update the database as needed using that scheme. The actual code required is very simple: $sql = file_get_contents( plugin_dir_path(__FILE__) . "/schema.sql" ); dbDelta( $sql ); This will both create and ...


0

Try the following steps and it will probably allow you to update everything. Open wp-config.php and add ` define('FS_METHOD','direct'); The last step is to change the owner:group of the directory which you already did. Quick note, if you are using apache2, the group is www-data and not apache. So it would be like this sudo chown -R ...


0

I had to also change the owner of the root web directory. chown apache:apache . # or chown apache:apache /var/www/html


1

Only Super Admins should be able to update plugins for a MS install which means that it doesn't matter what site you're on and every site using that plugin will have it updated automatically.


1

Since you ruled out remove_action there is only one way you can do it. And you've guessed it: preg_repalce, substr mixture but with a little help and PHP DOM add_action('wp_footer', 'my_start_footer_ob', 1); function my_start_footer_ob() { ob_start("my_end_footer_ob_callback"); } add_action('wp_footer', 'my_end_footer_ob', 1000); function ...


0

How about post meta ? if ( ! update_post_meta (7, 'sent', '1') ) { add_post_meta(7, 'sent', '1', true ); }; add_post_meta Or options table or custom table


0

You don't have a meta_value in your query. From your code I can't tell what you're doing with the meta values but you should be able to do this: // Store this BEFORE you go into the second loop. $category = get_field('category'); // The arguments for the second loop 'post_type' => 'case-studies', 'showposts' => 3, 'meta_key' => 'category', ...


0

if ( defined( 'WP_CLI' ) && WP_CLI ) { class RegenThumbs extends WP_CLI_Command { var $errors = false; var $unique_size_name = 'past_favourites'; var $unique_size = 170; public function __construct() { global $wpdb; if ( !$images = $wpdb->get_results( "SELECT ID FROM ...


0

You can create a plugin or add this to the config file, but for 3.9.2 this worked for me. define('ALLOW_UNFILTERED_UPLOADS', true);


0

This seems to be due to the way WooCommerce manages the tax - you can choose to apply tax to shipping or without shipping and so the order does not take into consideration the coupon discount. We have written a modification of the process and added it to our site and GitHub here: http://raison.co/woocommerce-shipping-calculated-coupon/ I hope that helps. ...


0

<?php $currentlang = get_bloginfo('language'); if($currentlang=="en-US") $link_text = 'All Products'; else $link_text = 'Dummy Text'; ?> $return_string .= '<li class="wpc-category ' . $class . '"><a href="'. get_option('catalogue_page_url') .'">' . $link_text . '</a></li>';


0

<select name="year[0][name]" id="year_0_name" ... The variable "year" is a variable already used by the WordPress query system. Take a look at the top of the file where you see "$public_query_vars" to see the ones WordPress is already using and expecting to be something different than what you're sending to it. Use different variable names than ...


1

Great Snippet available here from the guys at CSS-Tricks: $thumb_id = get_post_thumbnail_id(); $thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true); $thumb_url = $thumb_url_array[0]; When I first tried this solution it kept throwing 'Missing Attachment' because I was referencing the post ID instead of the attachment ID. ...


1

WordPress does not look for test.php; instead, you load it in your browser, like http://example.com/test.php.


0

In your $args array, you should be able to add 'posts_per_page' => -1 to show all products. The result would look like this: $args = array( 'post_type' => 'product', 'paged' => $paged, 'posts_per_page' => -1 );


0

check the get_current_blog_id function; that'll return the ID of the current blog.


0

I agree with G.M. about his answer. If you use a Plugin, that generates a custom-post-type i assume, that you also have a template for the non-archived lessons in your plugin folder, since somehow you will want to query it with its specific Arguments, no? That means you can use the code of G.M. to achieve that: add_filter('template_include', ...


0

i added this hook to function.php file. add_action('save_post','redirect_page'); function redirect_page(){ $type= get_post_type(); switch ($type){ case "post": $url= admin_url().'edit.php?msg=post'; wp_redirect($url); exit; break; case "product": $url= ...


0

Did you create wp-plug-in/wp-plug-in.php file in plugins folder and added this following code. <?php /** * Plugin Name: Load FontAwesome * Version: 1.0 */ /* Exit if accessed directly */ if ( ! defined( 'ABSPATH' ) ) exit; function wp_styles() { wp_register_style( 'font-awesome', plugins_url( 'wp-plug-in/css/font-awesome.min.css' ) ); ...


0

You got to include the fonts too if you are delivering the css from your plugin. Or, just enqueue the font awesome css from their CDN. add_action( 'wp_enqueue_scripts', 'wp_styles' ); function wp_styles() { wp_register_style( 'fontawesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css', array(), '4.2.0' ); ...


2

It seems like the plugin you are using are quite important to you and/or your client, and the plugin itself is most probably regulary updated with proper support. I would definitely contact the author and discuss possible changes to the plugin. If a change is a constructive change and would bring some degree of usefulness to the plugin, I see no reason why ...


0

if the plugin you are wanting to manipulate exists as a class, you might be able to overwrite it with __call function in your class (extends the original). that keeps you from editing files; you might have to rewrite your plugin to keep up with the other plugin, but I think extending the plugin's class is your best option, given the author's neglect.


1

Just because you think that you have to do it doesn't remove the fact that it is very not smart to do it. The plugin code is built to be used as a plugin and not as a theme, and while you can copy parts of the code and use them in the theme there can not be any simple way to make sure there is no dependency left somewhere in the code. The easiest way to do ...


0

I can think of not even one example to a plugin that do not use filters. Almost all plugins use options to store data and therefor use the option related hooks. your plugin probably uses many actions and filters, they are not on its high level code, but it does not prevent you from using them to change the plugin's behavior. Another possibility is to use ...


0

One of the things that confused me when using ajax was that die() is necessary at the end of the ajax callback function. Another issue is with the path(s) If you use get_template_directory_uri() and you use a child theme then you get the parents folder. If you use get_bloginfo('stylesheet_directory') and you us a child theme then you get the current child ...


0

You could use filter post_updated_messages : //Message handling when updating posts function set_messages($messages) { global $post, $post_ID; $post_type = get_post_type( $post_ID ); $obj = get_post_type_object($post_type); $singular = $obj->labels->singular_name; $messages[$post_type] = array( 0 => '', // Unused. ...


0

Generally for creating child theme you must use like this for example if you want to create a child theme for twentytwelve theme. First you want to make a copy of the twentytwelve theme and paste in same theme section and rename the copied folder into some other name you want in here I named as theme1child in this theme1child you should delete the ...


0

As per WP Code Snippet blog, it looks like this is one way: Add this code snippet to your functions.php file. // add async and defer to javascripts function wcs_defer_javascripts ($url) { if (strpos($url, '.js') === FALSE) { return $url; } if (strpos($url, 'jquery.js')) { return $url; } return "$url' async ...


1

You can use the get_post_thumbnail_id to get the ID of the thumbnail, then with the function wp_get_attachment_image_src you can get the image of the size you want, including full size, using the second paramenter. $thumb_id = get_post_thumbnail_id(get_the_ID()); $thumb_data = wp_get_attachment_image_src( $thumb_id, 'full'); Now in $thumb_data you ...


0

I'm making some brief assumption based on the way you have typed your question.. "After moving the plugin to the theme folder" Meaning you have taken the plugin from the plugin directory to your wp-content/themes/THEME_FOLDER. If this is the case then calling plugin_dir_path( __FILE__ ) will be unsuccessful in finding your file. You would need to use ...


0

First, if meta key is isbn_metadata is the meta_key you should specify this meta key instead of _isbn. Second, get_post_meta return an array unless you set the third parameter to true. So, you can do this: function get_kalahari_affiliate_link() { $isbn_metadata = get_post_meta( get_the_ID(), 'isbn_metadata', true ); if( ! empty( $isbn_metadata ) ) ...


1

You need to set your ACF field to return the image object instead of the URL. You can then use the following code to retrieve the image and alt text: <?php $slideshow_image = get_field('slideshow_image'); // Check for alt text - if there isn't any, use the image title $alt = ($slideshow_image['alt']?$slideshow_image['alt']:$slideshow_image['title']); // ...


0

Auto show a page in a navigation bar is not a standard feature of Wordpress. It is a specific feature of theme or plugins. If the theme you are using has this feature and you don't want it you will need to create a child theme and modify this behaviour. Anyway, what you have described is really better done with a custom post type. Think about it. You are ...


0

I assume that you want to activate a plugin only when it is necessary. There is a better option to do this. You can activate the whole plugin upon a certain action. I have provided a example code that will help you achieve what you are looking for and if you have any more queries you can put a comment. If it works for you can accept the answer. function ...


1

You can use the archive_template hook to process the content of a theme's archive template, by using the scheme below, but obviously you'll only ever be able to process a fraction of the themes out there, given that a template can basically contain any old thing. The scheme is to load the template into a string ($tpl_str) in the archive_template filter, ...


0

For scritps and using the wp_register_script() function, you can define the dependeny of jQuery in the $deps argument, which is documented as: $deps: Array of the handles of all the registered scripts that this script depends on, that is, the scripts that must be loaded before this script. These scripts will automatically be enqueued when this script ...


0

The conditional tags must be run after WP object is set up. The wp action hook is the first one through which you can use these conditionals safely. See the warning message in the conditional tags documentation. So, you should hook into wp action (note also that the correct function name is add_action, not add_Action): add_action('wp', ...


0

I had a similar issue and i found this, https://github.com/wpexplorer/page-templater/blob/master/pagetemplater.php it works quite well, the template file ofcourse needs to be created in the plugin and I put general styles that would change according to the theme it was on. Although there are a few issues though doesn't work exactly as a template would for ...


2

Please use $wpdb to interact with the Database. global $wpdb; $wpdb->update( // Table name $wpdb->posts, // New values array( 'post_type' => 'product', ), // SQL "WHERE" clause base / affected rows array( 'post_type' => 'post', ), // Data Type (available: %s string, %d integer, %f float) '%s', // SQL "WHERE" ...


0

Try something like this: if ( !function_exists('get_field') && $_REQUEST['action'] != 'activate' ) This will prevent your function being defined for the run where a plugin is actually being activated.


0

Fellow readers, here is a link to the WordPress Polylang plug in as asked of a forumnist Before I understood what I was doing, I used Polilang to create three independent versions of the saame category, one French (Administration), one English (Admin), one Spanish (Administración). I later realized that these categories were not considered translations of ...



Top 50 recent answers are included