Are you the publisher? Claim or contact us about this channel

Embed this content in your HTML


Report adult content:

click to rate:

Account: (login)

More Channels


Channel Catalog

Channel Description:

WordPress › Support

older | 1 | .... | 347 | 348 | (Page 349) | 350 | 351 | .... | 413 | newer

    0 0

    Yes I have searched and yes I have found lots of answers, but I am not sure I have found the correct answer.

    I have a form with an image upload. I am using wp_handler_upload() to upload the image to my uploads file. The code works fine as long as 'test_form' => false is in the $overrides array. So here is my question everything I have found online says to set this this way, but in the codex it says

    (array) (optional) An associative array to override default behaviors. When called while handling a form, 'action' must be set to match the 'action' parameter in the form or the upload will be rejected. When there is no form being handled, use 'test_form' => false to bypass this test, and set 'action' to something other than the default ("wp_handle_upload") to bypass security checks requiring the file in question to be a user-uploaded file.

    Default: false

    The source file says

    // All tests are on by default. Most can be turned off by `$overrides[{test_name}] = false;
    $test_form = isset( $overrides['test_form'] ) ? $overrides['test_form'] : true;
    $test_size = isset( $overrides['test_size'] ) ? $overrides['test_size'] : true;`

    // If you override this, you must provide $ext and $type!!
    ` $test_type = isset( $overrides['test_type'] ) ? $overrides['test_type'] : true;
    $mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : false;`

    // A correct form post will pass this test.
    ` if ( $test_form && ( ! isset( $_POST['action'] ) || ( $_POST['action'] != $action ) ) ) {
    return call_user_func( $upload_error_handler, $file, __( 'Invalid form submission.' ) );

    So my questions are first how do I set action to my forms action parameter? I tried 'action'=>'' which didn't work.

    Second is setting 'test_form' => false just an easy fix that is bypassing a security measure? or is it really supposed to be set that way? The only example in codex uses it and every example I have found online uses it, but it says a form should be able to pass the test. I am so confused.

    Here is my current code:

    if ( ! function_exists( 'wp_handle_upload' ) ) {
    				require_once( ABSPATH . 'wp-admin/includes/file.php' );
    			$uploadedfile = $_FILES['fileToUpload'];
    			$upload_overrides = array( 'test_form' => false, 'mimes' => array('jpg' => 'image/jpeg', 'png' => 'image/png') );
    			$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
    			if ( $movefile && !isset( $movefile['error'] ) ) {
    				echo "File is valid, and was successfully uploaded.\n";
    				//var_dump( $movefile);
    			} else {
    				 * Error generated by _wp_handle_upload()
    				 * @see _wp_handle_upload() in wp-admin/includes/file.php
    				echo $movefile['error'];

    and the form

    <form method="post" action="<?php echo htmlspecialchars('');?>" enctype="multipart/form-data">
       <input type="file" name="fileToUpload" id="fileToUpload"><br>
       <input type="submit" name="submit" value="Save">

    0 0
  • 01/28/16--16:22: njkuiper6 on "Deployer App"
  • Hi,

    I was wondering if anyone has used
    and how it has worked for them.


    0 0

    Hi all,

    Very new to anything like this in WordPress. Perhaps I'm going about this the wrong way but I'd like to cache some request data to tone down network requests by caching the data.

    In typical PHP you could use a good old fashioned $_SESSION, or I'd just use JavaScript myself and write it to localStorage. Since I see relatively very little out there in regards to using $_SESSION with WordPress it just feels like I may be overlooking an API on the WP side.

    I do see sessions.php for user metadata but it seems to be more oriented toward expanding registered user data.

    The data that I'm trying to cache is page content that has nothing to do with the current using pulling it. It's 100% public, content from a remote site.

    As best I can figure, if I use WP's REST API to pull the data (in a plugin), save the request with an expiring timestamp in a table local to the WP site then I can pull that data for every request without hitting the API. Once the timestamp is exceeded I'd re-pull the data and update it.

    Is this nature outside of anything WP-friendly? Is there another class or path I should be considering for this? I'd like to keep the data pull server-side in PHP for this.

    Thanks for tips!

    0 0

    I'm struggeling with this for two days, and Google, nor my "WordPress Plugin Development" handbook can help me. I'm really out of options.

    Summarized, I'm building a (FAQ) plugin and I have trouble loading the text domain.
    If I load it the 'traditional' functional way, it works fine.
    If I put it in the constructor of a class, it fails.
    The code below is trimmed to loading the text domain only, but the same constructor also creates a custom post type and a custom taxonomy, and that works just fine. So the problem in the constructor is restricted to loading the text domain only.

    For your perception: This is the first time that I build a plugin the OO way. So it is also quite possible that I have an error in my code. However I haven't found it yet.

    This works fine (functional method):

    /** Load text domain */
    add_action('plugins_loaded', 'wdfaq_load_textdomain');
    function wdfaq_load_textdomain() {
    load_plugin_textdomain( 'wd-faq', false, dirname( plugin_basename(__FILE__) ) . '/languages/' );

    This doesn't load the text domain (OO method):

    class wd_faq {
    	/** Constructor */
    	public function __construct() {
    		add_action('plugins_loaded', array($this,'wdfaq_load_textdomain'), 0 ); // Load text domain
    	/** Load text domain */
    	public function wdfaq_load_textdomain() {
    		load_plugin_textdomain( 'wd-faq', false, dirname( plugin_basename(__FILE__) ) . '/languages/' );
    $faq = new wd_faq();

    Neither does this (OO method simplified):

    class wd_faq {
    	/** Constructor */
    	public function __construct() {
    		load_plugin_textdomain( 'wd-faq', false, dirname( plugin_basename(__FILE__) ) . '/languages/' );
    $faq = new wd_faq();

    I have checked the file names and they are OK:

    (Btw, if they were not OK, the functional method would fail too of course)

    0 0

    I have a private theme that contains a .json and .zip, this works fine hooking into pre_set_site_transient_update_themes.

    However during the installation process it will download and unpack the zip into wp-content/upgrade with a random hash on the end of the filename, so => theme-kw342.

    This is a problem as when it moves (and deletes the current theme) into wp-content/themes it doesn't rename the folder to theme, it keeps it as theme-kw342 which means my theme breaks.

    I have resorted to renaming the folder when it's in wp-content/upgrade (by hooking into upgrader_source_selection) but it doesn't seem right.

    Any ideas?

    This is a gist of my code, get_config and debug_log are helper function I have created.

    For reference, my theme.json:

    	"new_version": "0.1.38",
    	"url": "http:\/\/\/updates.html",
    	"package": "http:\/\/\/"

    0 0


    This is a bit of a mish mash problem, so am posting here, instead of in the root.

    I am using a theme on my website "Smoothie -" which uses masonry to display posts. As far as I can tell, the theme has been abandoned by the developer.

    I have tried using several plugins to hide specific posts from the homepage (simply exclude, WP Hide Post etc). The plugins work great, but when I click the "Load More" link, to load the next 10 posts, the last post is duplicated at the beginning of the next 10 posts.

    If I hide 1 post, then the last post of the first 10 posts displayed is duplicated.
    If I hide 2 posts, then the last 2 posts of the first 10 posts displayed are duplicated.

    Is there anything I can add to the loop to check for duplicates? or how many posts were initially displayed?

    I have hidden 1 post on my test site, you can see the "Logo & Character Designs" post duplicating as a result when you click "Load More" here:

    Many thanks

    Mr M

    0 0

    I got this code for the sale start & end date, So it shows on a product page:

    add_action( 'woocommerce_single_product_summary', 'woocommerce_output_sale_end_date', 10 );
    function woocommerce_output_sale_end_date() {
    $sale_end_date = get_post_meta( get_the_ID(), '_sale_price_dates_to', true );
    if ( ! empty( $sale_end_date ) )
    echo '<span id="sale-price-to-date">' . __( 'Sale End Date: ', 'woocommerce' ) . date( 'Y-m-d', $sale_end_date ) . '</span>';

    Somehow I need to ad this code, so it picks up the drop price timeframe from the drop price plugin for woocommerce instead of the sale end date:

    $drop_price_dates_from 	= ( $date = get_post_meta( $post->ID, '_drop_price_dates_from', true ) ) ?  $date  : '';
    $drop_price_dates_to 	= ( $date = get_post_meta( $post->ID, '_drop_price_dates_to', true ) ) ?  $date  : '';

    I also got this code to show the drop price timer on the homepage, but I want it to show the drop price timeframe. Any solution?

    add_action( 'woocommerce_after_shop_loop_item_title', 'wpgenie_show_counter_on_loop',50 );
    function wpgenie_show_counter_on_loop(){
    	global $product;
    	if(!isset ($product))
    	if (isset($product->drop_price_counter) && ($product->drop_price_counter == 'yes') && isset($product->drop_price_next_drop) && $product->drop_price_next_drop){
    		echo '<div class="drop-price-counter">';
    		echo '<div class="drop-price-time" id="countdown">
    				<div class="drop-price-countdown" data-time="'.$product->drop_price_next_drop.'" data-productid="'.$product->id.'" ></div>
    		echo "</div>";

    0 0

    I'm building a website on WordPress with a Genesis child theme called Prestige. The installation of the child theme included importing pages from a .xml file. Now I've got pages in Wordpress (from the .xml file) that I want to edit in a text editor but I don't know how to download them to my local computer for editing. How can I edit the pages I imported via the .xml file?

    0 0

    I'm working on a new theme based on a theme that has worked well for years. But an odd problem has occurred. I issue a call to a method. The code after the call is exectued. But the method code itself doesn't get executed. I added some echo and die statements to illustrate the problem. Here is the code involing te method:

    echo "Calling getByDateOrder";
          die("Called getByDateOrder");

    Here is the invoked code:

    public function getByDateOrder($fdate) {
                 global wpdb$;
                 die("getByDateOrder entered");
                 $query="SELECT * FROM ncrj_donors WHERE lgdate >= '$fdate' ORDER BY lgdate";
                 $wpdb->query($query) or die("getByDateOrder Failed");
                 if ($num==0) {
                    return false;
                 $this->result=$wpdb->get_row($query) or die("Donor Query Failed");
                 return true;

    The code after the die statement shouldn't matter.

    But here is the result:

    Calling getByDateOrderCalled getByDateOrder

    I've never encountered a problem like this before. Has anyone else? any suggestions about how to debug?

    -Bob Chatelle

    0 0


    I'm trying to edit the register page on my theme so that when a user logs in for first time after registering via social log in, they can still choose a username and fill out profile data on the default register page.

    The problem I'm having at the moment is I can't find the code that redirects logged in users to the home page when they visist the register page.

    Anyone know how where I can find it so I can edit/hack it?

    I'm using buddypress plugin also btw.



    0 0

    How can I change pop out menu color?

    0 0

    Hi there, I'm trying to find a way to have a set size and potentially hard crop images using the catch_that_image function.

    At the moment, I'm using featured images primarily, but have older posts which don't have any. Because I have a section that show a random group of posts with images I decided to use catch_that_image in an if/else statement to make sure something showed up.

    Now for featured images I have the following code

    if ( function_exists( 'add_theme_support' ) ) {
    	add_theme_support( 'post-thumbnails' );
            set_post_thumbnail_size( 150, 150 ); }
    if ( function_exists( 'add_image_size' ) ) {
    	add_image_size( 'article', 600, 250, true );
    	add_image_size( 'recent', 150, 70, true );
    	add_image_size('homepage', 200, 200, true);
    	add_image_size('slider', 400, 190, true);

    So I really am hoping there is a way to use add_image_size or something similar to catch_that_image in order to do the 150x70 true option. I can set the size with html, but then it distorts the image pretty bad depending on original size.

    Also here is my catch_that_image code and the code I'm using to call that or the featured image.

    Catch_that_image code.

    	function catch_that_image() {
      global $post, $posts;
      $first_img = '';
      $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
      $first_img = $matches [1] [0];
      if(empty($first_img)){ //Defines a default image
        $first_img = "/images/logo.png";
      return $first_img;

    Code calling the images.

    if ( has_post_thumbnail() ) { ?>
        <p class="image"><a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php  the_post_thumbnail( 'recent' );  ?></a></p>
    <?php } else{ ?>
    	<p class="image"><a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>"> <img src="<?php echo catch_that_image() ?>" alt="<?php the_title(); ?>" /></a></p>
    <?php } ?>

    I've tried just using the options from the add_image_size functions, but those don't work, and I've tried different variations in the catch_that_image function as well.

    I appreciate any help or insight anyone has.

    0 0


    Could you please help me to understand - how I can change list of available translations on the plugin page in the repository?

    I have published plugin , in the /lang/ sub directory it contatins .po and .mo files for Russian and German translation.

    However translations list in the right column on the page contains only Russian translation, while German translation not appeared.

    0 0

    After seeking a solution about thumbnail size, I found in wordpress codex some codes and when i add them in editor in function php my blog stopped working. It is a blank page with this error message :

    Parse error: syntax error, unexpected end of file in /home/taskylon/public_html/wp-content/themes/easel/functions.php on line 487

    I opened my cplesk profile but I cant see the specific line. I assume the problem is here:

    if (!function_exists('easel_display_post_thumbnail')) {
    function easel_display_post_thumbnail($size = 'thumbnail') {
    global $post, $wp_query;
    if ($post->post_type == 'post') {
    $post_thumbnail = '';
    $link = get_post_meta( $post->ID, 'link', true );
    if (empty($link)) $link = get_permalink();
    if ( has_post_thumbnail() ) {
    if (is_home()) {
    $post_thumbnail = '<div class="post-image"><center>'.get_the_post_thumbnail($post->ID, $size).'</center></div>'."\r\n";
    } else
    $post_thumbnail = '<div class="post-image"><center>'.get_the_post_thumbnail($post->ID, $size).'</center></div>'."\r\n";
    } else {
    $url_image = get_post_meta($post->ID, 'featured-image', true);
    if (!empty($url_image)) $post_thumbnail = '<div class="post-image"><center><img src="'.$url_image.'" title="'.get_the_title().'" alt="'.get_the_title().'"></center></div>'."\r\n";
    echo apply_filters('easel_display_post_thumbnail', $post_thumbnail);

    Could you please tell me where exactly is the problem and how to fix it?
    Thank you

    My blog is

    0 0

    Based on the path, I'm able to write custom routes to get the correct page, and set some custom variables... for example:

    If the route takes a URL in this format:

    And we hit this URL:

    And we're able to retrieve the page by doing:


    Right now, the original query initially searches for products/baseball-glove which returns the WP_Post object for 404 / Page Not Found, even though my subsequent query with get_page_by_path gets me the correct WP_Post object. How can I reset the global $post object to overwrite the current WP_Post and so that other plugins are able to use functions like the the_title()?

    0 0

    I have a site on which I embed a lot of videos. They almost always have a big play button centered on the video, which, if clicked once, plays the video.

    If I click that same spot to pause the video, instead of pausing, it just sends me to the page where I got the video. It's like the pause/play button becomes a hyperlink after the first click.

    Is there any way to disable this? I don't want embedded videos linking back to their sources, especially since they don't do so in a new window.

    And yes, I know this is probably shady. I've come to terms with that.

    Here's an example embed code

    <iframe width="560" height="315" src="" frameborder="0" scrolling="no" allowfullscreen></iframe>

    (it's an adult video, so I changed the name of the site to "example." The rest of the code is accurate).

    Any help would be much appreciated. Cheers!

    0 0

    i've used PHP inside the Sidebar to show a Message.

    <?php $HKS_geschlossen = TRUE; ?>
    <?php if ( $HKS_geschlossen): ?>
    <?php endif ;?>

    My problem now is, that I have some more People using that Site, who have to change the Value of $HKS_geschlossen. Is there a Way to create sth like a Checkbox in the Admin-Bar where people with rights can change the Value? Thats what I thought is easy to use for "non-coders". If that doesn't work, does sb. know another way to simply change a Value to display/not display a part in the sidebar?

    Site is:


    0 0

    Hi All,

    I'd like to just print the main level of navigation on my theme, but capture just the subnav of the immediately selected nav item (if there is one).

    I copied the standard Walker class to extend it and made extremely light changes. Essentially at the top of start_el/start_lvl/end_lvl/end_el I check the depth and anything above 0 I just return;.

    Pastebin example:

    At the bottom of the pastebin you can see what I'm getting for output. To put it here for ease, it's very simple.

    My menu is simple like:

    Menu 1
       Subnav 1
    Menu 2
    Menu 3

    I want to print the main "Menu #" items. The problem is I'm getting an empty <ul class="sub-nav"> inside of Menu 1. I do not get the < li > items inside it, just the empty container.

    Anyone have any idea why I would get this empty <ul class="sub-nav">?

    I know I can set the $args to have depth => 1, or just set .sub-nav{display:none;} but I'd really like to understand the Walker class a bit better to start making better navigations.

    Thanks for any tips!

    0 0

    I am building a pure javascript tool and I want it to be able to make modifications to an existing post. The javascript runs inside the post, so there should be no cross origin problems. I looked at the rest api and wpcom.js but they seem to require me to know the access token, which looks like an HttpOnly cookie.

    Anyone have a working example of this?

    0 0

    I have two page templates (prose, poetry), and each one has a css file associated.
    I realised that if I create a new page with a specific page template the associated css file works only after I either publish the content or save it as a draft.
    Is there a way to have the visual editor style set before I start writing?
    I know I can always write the title, save it as a draft and by then the style is loaded into the visual editor.

    Thank in advance.

older | 1 | .... | 347 | 348 | (Page 349) | 350 | 351 | .... | 413 | newer