mercredi 31 décembre 2014

Woocommerce- How to limit the orders (admin side order listing) with respect to vendor?


I am using the Woocommerce Vendor Stores plugin along with WooCommerce so that I can add the multiple vendor functionality to the woocommerce store. But the problem right now is a vendor should be able to see his orders only (now he can see every orders). A vendor is a user with a role "vendor" created by the plugin. Every products listed by the vendor will be show in his particular store. Basically a store is a term with a term taxonomy "shop_vendor" .enter image description here


Can someone please tell me how to achieve this (limiting the orders with respect to the vendor)





Security of using uploaded file across two admin submits


I'm writing a plugin that merges two files, based on user input about which file to draw each section from. This means that I have to get the user upload and display it before I can get the user input for the actual merge.


My question is about the security and best practices for the uploaded file. Since I can't process it until the second submit, I can't just stick the name back in the form as a hidden input. It would have to be uploaded again. I can move the temporary file to a new name and put that name as a hidden input, but is that secure? I have no way to know if there is code in the file, although I make sure it matches a file extension and a 10 byte header, and of course the plugin is checking for 'manage_options' capability along with the nonce. Would it be better to put it in a cookie instead of a form field? I don't want to put it in the database, not just because of security, but because it limits it to one use at a time.





Ajax not working wordpress


js file:



jQuery.ajax
({
url: '<?php echo admin_url("admin-ajax.php"); ?>',
type: 'POST',
data: {
'action':'myaction'
},
success: function(data)
{
alert('Happy new year 2015 :) ');
},
error: function(data)
{
alert( 'Sorry! No Happy New year 2015 :(' );
}
});


php file:



// Ajax Handler.
function so_enqueue_scripts()
{
$plugin_dir_path = dirname(__FILE__);
$plugin_url = plugins_url();
wp_enqueue_script( 'ajaxHandle', $plugin_url . '/walking-log/js/walking_log.js', array('jQuery') );
wp_localize_script( 'ajaxHandle', 'myAjax', array( 'ajaxurl' => admin_url( 'admin_ajax.php' ) ) );

add_action( 'wp_ajax_myaction', 'so_wp_ajax_function' );
add_action( 'wp_ajax_nopriv_myaction', 'so_wp_ajax_function' );
}
add_action( 'init', 'so_enqueue_scripts' );

function so_wp_ajax_function()
{
die();
}


path of walking-log.js is right, i have opened in the browser. I am getting the success failure alert. don't know why. any help would be appreciated.





Removing rel="nofollow" from links posted in Post Content


I am running wordpress for my blog EasyPadhai.


I am writing a posts and I have included links to my Android app EasyPadhai for my users. But all links to app are turning in nofollow links. Also Social-links are becoming nofollow links.


How can I change this, so that links in post_Content become doFollow. I am not a pro-wordpress dev. Also I am using following plugins on my installation.



  • Akismet

  • Google Analytics for WordPress

  • WordPress SEO

  • W3 Total Cache


How can I change nofollow links to do follow links for my Post Content?





Error: How to allow the “contributor” to upload media in wordpress


am facing a problem with my wordpress site.In my site I prevent/disallow the "contributor" to upload media files.


But I want them to upload only the featured image. So what is the trick in that case?? Is there any code?? or any plugins?? I searched a lot but found nothing related to it. I badly need that. Please help me. Thanks in advance.


I try this code :-



if ( current_user_can('contributor') && !current_user_can('upload_files') )
add_action('admin_init', 'allow_contributor_uploads');
function allow_contributor_uploads() {
$contributor = get_role('contributor');
$contributor->add_cap('upload_files');
}


But when contributor start upload media, its show him an error and cannot upload images and download this file :-



async-upload.php




Can we make page template in thesis 2.1 framework?


I need to create custom page template in thesis framework(version 2.1) just like we create in WordPress(full-width template/home page template/other page template,etc.).


Is there a way to do so?


Please give a solution.





using the filter 'upload_dir'


I want to override the /year/month scheme and upload my files to a specific folder. I've copied the following code form codex.wordpress and inserted in my theme functions.php:



add_filter('upload_dir', 'awesome_wallpaper_dir');

function awesome_wallpaper_dir( $param ){
$mydir = '/awesome';

$param['path'] = $param['path'] . $mydir;
$param['url'] = $param['url'] . $mydir;

return $param;
}


but when I upload a file it is stored in /year/month subdir. What's wrong?





Serialized Data Being Cut Off?


I have two separate installations of WP on two servers. They're both the exact same website. In my CPT's meta, I have a field that's a very long piece of serialized data. On one server the full data is saved, on the other server the data gets cut off.


Has anyone experienced this before? Let me know what would help diagnose this issue and I'll upload it ASAP!





Limit filetype and wp media


This is my input markup:



<div class="button-primary" id="fileToUpload">Upload</div>


This is js:



jQuery( '#fileToUpload' ).click( function()
{
var custom_uploader = wp.media
({
title: 'Select',
button: {
text: 'Select'
},
multiple: false // Set this to true to allow multiple files to be selected.
})
.on( 'select', function()
{
var attachment = custom_uploader.state().get( 'selection' ).first().toJSON();
jQuery( '#previewImage' ).attr( 'src', attachment.url );
jQuery( '.custom_media_url' ).val( attachment.url );
jQuery( '.custom_media_id' ).val( attachment.id );
})
.open();
});


I want to limit the the file type to jpg,jpeg and png. How can i achieve this?





Editor meta box Showing but not saving


I am trying to create an editor meta box and I have been following tips found in other similar questions without luck in getting the meta box to save and display its content. The meta box shows but when I write anything it doesn't get saved. Please help! I've been at this for hours without any luck.


Here is my code at the moment:



add_action( 'add_meta_boxes', 'add_educadme_related_resources_metabox' );
// Add the Custom Fields Meta Boxe
function add_educadme_related_resources_metabox() {

add_meta_box('educadme_related_resources', 'معلومات إضافية', 'display_educadme_related_resources', 'lesson', 'normal', 'high');

}


// Display The Custom Fields Meta Metabox
function display_educadme_related_resources( $post ) {

// Get the resources data if its already been entered
$educadme_resources = get_post_meta($post->ID, 'related_resources', true);
wp_editor( $educadme_resources, 'related_resources');

}

add_action( 'save_post', 'save_educadme_related_resources' );
// Save Function
function save_educadme_related_resources( $post_id ){
// Is the user allowed to edit the post or page?
if ( !current_user_can( 'edit_post', $post_id ))
return;
// check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return;
}
// If empty don't do anything (don't save)
$related_resources = get_post_meta($post_id, 'related_resources', true);
if(!$related_resources OR $related_resources == '') return;

// OK, authenticated: we need to find and save the data
if ( isset ( $_POST['related_resources'] ) ) {
update_post_meta( $post_id, 'related_resources', $_POST['related_resources'] );
}

}




Paypal IPN variables - what kind of failed transactions are retried


I'm developing a module that handles IPN calls from Paypal. From the documentation, I see that when txn_type = 'recurring_payment_skipped', the IPN will be retried up to 3 times, 5 days apart. But what about other transaction types, such as 'subscr_failed' and 'recurring_payment_failed'? Do they enter the retry process as well or are they sent once only?


Thanks!


PS: I just moved this question from money.stackexchange.com and I'm only putting it here because I don't see any other SE website that's more fit.





Wordpress Custom Post Type is not working properly


I'm creating custom WordPress theme and i'm in trouble, i have created the custom post type when i visit the custom post type all styles are gone and when i inspect element that page all html elements are different like classes and div which are not included in that custom post type file.


I'm Searching Google from last one day everyone is saying this problem occurred due to irrelevant use of flush_rewrite_rules(); and i'm using this function only once when theme will change.


When i change the permalinks from admin panel to default everything working great but when i change again permalinks to postname, numeric and month & name same problem occurred all style from custom post type are gone it showing different div and classes when i inspect element that page.


Below is the code for custom post type.



function my_custom_post_product() {

$labels = array(
'name' => _x( 'Portfolios', 'post type general name' ),
'singular_name' => _x( 'Portfolio', 'post type singular name' ),
'add_new' => _x( 'Add New', 'book' ),
'add_new_item' => __( 'Add New Portfolio' ),
'edit_item' => __( 'Edit Portfolio' ),
'new_item' => __( 'New Portfolio' ),
'all_items' => __( 'Portfolio Items' ),
'view_item' => __( 'View Portfolio' ),
'search_items' => __( 'Search Portfolio' ),
'not_found' => __( 'No portfolio found' ),
'not_found_in_trash' => __( 'No portfolio found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'Portfolio'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our products and product specific data',
'public' => true,
'menu_position' => 40,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
'has_archive' => true,
);
register_post_type( 'portfolio', $args );

}

add_action( 'init', 'my_custom_post_product' );

function mytheme_setup_options () {
my_custom_post_product();
flush_rewrite_rules();
}
add_action('after_switch_theme', 'mytheme_setup_options');




Any kind of help would be appreciated.

Thanks





2015 theme issu


I was messing around with the 2015 theme and normally when you remove all the css, the theme display nicely in this naked state. The 2015 theme does not. When I scroll down the page, it jumps. I have tried twice on two different installs and get the same issue. I can't get it to scroll to the footer without the page jumping like crazy. Do you know why it would do this? I can't find anything. Putting the css back in makes it work just fine.





Best way for overwriting plugin css with custom one


I've to do very little changes to bbPress (forum plugin for wordpress) for a customer, at all about 5 lines css only. But I'm not sure where is the best place to put this css code. Modify the original plugin css files seems not to be a good idea because it may be overwritten on the next update and it's hard to see what was modificated.


My second idea was to place the css code in the main css-file of the theme. This seems a bit better, but the customer is using a paid-theme which get updates too. So these changes will be lost in case of theme-updates.


Where is the best place to put such css-modifications so that they're not getting overwritten by updates of wordpress, themes or plugins? Wordpress is developed very modular so it seems for me that this is not possible without extra-work (which has to be documentated and regarded on every update).





With over a page of content the footer remains where the bottom of the screen was at top scroll


I've been building an artist website to promote my music and I've ran into an obstacle with my footer. What I want is very simple (or so it would seem). I'm trying to create a footer that sits under the content/body and is at the very bottom of the site. No white space on the left, right, or bottom. Then when the site has minimal content the footer will sit at the bottom of the screen. The problem that I'm running into is that when the content is more than a page long, instead of pushing the footer down with it, the footer just sits where the bottom of the screen is (when scrolled to the top). This means that when the user scrolls to the bottom of the site, the footer remains in the middle somewhere, overlapping content.


I wish I had kept track of all the sites and forums I've been on and tried, but It's been several full days of searching. It's better than when it started (originally I couldn't push the left and right margins to full width), but this last problem is just evading me. Any help would be very much appreciated. (I am using a Wordpress Twenty-Twelve Child Theme if that helps)


Undesired Footer


Desired Footer


My current hypotheses are as follows:




  1. There is code somewhere that makes the footer stick to the bottom of the screen with minimal content, and it is constantly applied. From what I understand, the way people do this is by using min-height:100%, but with/without that line it makes no difference.




  2. Maybe there is something not right in terms of my html hierarchy? Twenty-twelve used #masthead, #page, #main, and #colophon. I've come across a couple sites where people say to make sure the footer is outside of the main wrapper. I've done this but it hasn't worked.




  3. Maybe the issue is not in footer at all? Maybe the other containers need to be changed. Maybe #main needs to be set to position:relative; or something (but that hasn't worked).




Here's all the html:



<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<header id="masthead" class="site-header" role="banner">

<nav id="site-navigation" class="main-navigation" role="navigation">
<button class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></button>
<a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
</nav><!-- #site-navigation -->
<?php if ( get_header_image() ) : ?>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php header_image(); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /></a>
<?php endif; ?>

</header><!-- #masthead -->

<div id="main" class="wrapper">

</div><!-- #page -->
</div><!-- #main .wrapper -->
<footer id="colophon" role="contentinfo">
</footer><!-- #colophon -->
<?php wp_footer(); ?>

</body>
</html>


And here's the footer css:



footer {
background:url(http://ift.tt/1zxmbfw) repeat-x bottom center;
height:100%;
width:100%;
position:absolute;
margin:0px;
padding:0px;
bottom:0px;
min-width:100%;
}


Here's the site itself: www.kjel.ca (stackexchange won't let me post more than two links)


Also note that I have tried Ryan Fait's sticky footer which I've seen referenced quite a bit. I haven't been able to get it to work properly. I'm not a professional coder, I'm a musician with a basic knowledge of html and css trying to save cash. If I'm going about the footer the complete wrong way, feel free to set me straight. Any help is most appreciated!





Custom permalink parameter isn't enforced


I'm trying to create a custom permalink for my posts based on a custom field. I'm most of the way there but I'm struggling with the last part.


My goal permalink structure is as follows:



/%category%/%postname%/%location%


%location% will be replaced with the value of the custom field on my post which I added using the add_meta_box hook. I'm using the post_type_link and post_linkfilters to parse the permalink.


So far, so good. When I open up my home page I can see the posts are being generated with the correct permalinks. Clicking on any of the post links takes me to the correct post page too.


Here is where my problem is. The %location% part of the permalink is completely ignored. I can remove this from the URL or enter an incorrect value but the post is still displayed. So long as the /%category%/%postname% part is correct Wordpress will always show the post page.


This isn't how it should work. If the %location% segment is either missing or doesn't match the value of the location field on the post then it should 404.


How can I get Wordpress to enforce my custom structure when displaying the post page?


Thanks





WooCommerce display price breakdown in product page


I Have woocommerce installed. I would like to show the total price of a product , and how it came to be(the product's price breakdown). To make things clear I am including this. I would like something similar to the 'price configurator' from the attached link.


If you change variants, the price changes , and some other fields as well.


I would like to have something like that chart in each of my product's page.





WooCommerce Multisite and shared images


Perhaps this isn't exactly the best plugin reference, but here it is anyhow: http://ift.tt/1A5jkP4 Now, here's a handy dandy video I made, because talking is a lot easier http://ift.tt/1tB6acc So... in a nutshell, we need to share the media that goes with 'Featured Image' and 'Product Image'.


How can we make this happen?





Why query_vars get altered in WP_Query Object?


I am having problems when querying a WP_Query Object when a user has a role different than administrator


My WP_Query is this:



$query = new WP_Query( array(
'post_type' => 'custom_post_type',
'author' => $author_id,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'value_id',
'value' => $value_id,
'compare' => 'LIKE',
),
),
'order' => 'ASC'

));


For some reason when the query is run by a user other than the administrator, this is the result:



WP_Query Object
(
[query] => Array
(
[post_type] => notification
[author] => 70
[meta_query] => Array
(
[relation] => AND
[0] => Array
(
[key] => value_id
[value] => 86
[compare] => LIKE
)

)

[order] => ASC
)

[query_vars] => Array
(
[post_type] => notification
[author] => 86 //<--- THIS SHOULD BE 70
[meta_query] => Array
(
[relation] => AND
[0] => Array
(
[key] => value_id
[value] => 86
[compare] => LIKE
)

)
[order] => ASC
...


Please notice the author in query_vars it is 86 when it should be 70. Why is this being altered?





Why does the google map display in a different place to the grey load area? WP jquery load issue


The google map loads, but doesn't display where the grey load box is, but lower down the page (around the footer area). I believe this is a Jquery load issue or a conflict with another plugin (the google map code is also in a well regarded plugin).


enter image description here


I have added the following code to functions.php, but it doesn't seem to help:



function insert_jquery(){
wp_enqueue_script('jquery', false, array(), false, false);
}
add_filter('wp_enqueue_scripts','insert_jquery',1);


Any suggestions please?





How to show/hide a meta box using categories, with a different post type


The following code hides a meta box when certain categories are selected using jquery, in post editor. It works with post as the custom post type. I need it to work with a custom post type called events. The event type uses a custom taxonomy called event categories, I want to use the ids in these categories with the event post type. Here is my working code that works with the standard post type:


add_meta_box.php in the plugin folder:



function add_custom_box() {
add_meta_box(
'my-meta-box', // id of metabox
'My Custom Meta Box', //title of metabox
'my_callback_function', // callback function that will echo the box content
'post' // posttype to add meta box
);
}
function my_callback_function() {
echo '<label for="my_meta_box_text">Text</label>: <input type="text" id="my_meta_box_text" name="my_meta_box_text" />';
}

if (is_admin())
add_action('admin_menu', 'add_custom_box');

wp_enqueue_script('metabox_js', plugins_url('add_meta_box/js/metabox.js',dirname(__FILE__) ), array('jquery'));


metabox.js in pluginfolder/js/metabox.js:



jQuery(function($)
{
function my_check_categories()
{
$('#my-meta-box').hide(); // intially hides the metabox

/* script to show metabox on category ids 2,3 and 4 (write the category ids in the if condition below on line 14)*/
$('#categorychecklist input[type="checkbox"]').each(function(i,e)
{
var id = $(this).attr('id').match(/-([0-9]*)$/i);

id = (id && id[1]) ? parseInt(id[1]) : null ;

if ($.inArray(id, [22,23]) > -1 && $(this).is(':checked'))
{
$('#my-meta-box').show();
}
});
}

$('#categorychecklist input[type="checkbox"]').live('click', my_check_categories); // calls the function on click of category checkbox

my_check_categories(); // calls the function on load
});


I know that I need to change post to event in add_meta_box, I have done this but it doesn't seem to work. Please can someone provide a bit of guidance, it would be really appreciated? Thank-you





mardi 30 décembre 2014

how to auto close topics in bbPress forum after some days?


I am new to wordpress and I'm trying to make a forum which has an announcement forum in which users can discuss new updates and news but I want the topics in that specific forum to be open for a limited time (3 days for example) and then close automatically.


I tried searching but I can't find a clear answer. There is no option for this either in the forum settings.


If I have to edit code, please explain step by step as I have never worked with php either.


thanks





Single page archive - get coresponding taxonomy and terms


For custom post type i have 12 taxonomies (12 months) and each of them with many terms (plant parts - roots, leaves, flowers etc.) On archive page i retrieve a data list with this



foreach($months as $month) :
$args = array( 'post_type' => 'branje_biljaka', 'posts_per_page' => 100,
'tax_query' => array( array(
'taxonomy' => $month,
'field' => 'slug',
'terms' => $plant_parts
)
)
);
$branje = new WP_Query( $args );


and it works perfectly. On a single archive page I am stuck. I don't know how to fetch any corresponding data other than the_title() but I need to fetch the same data for every month and all plant parts but only for that specific post.


I dont have any 'normal' data to echo like the_content, only those terms. I think I am complicating this more than I should and I believe Wordpress does this with much less work... but how do I expand the same query so it grabs only current single archive post title? Everything else should be the same...


Inserting something like 'ID' => get_the_ID() into arguments does nothing.





Images outside full content


I need to insert a picture or bootstrap carousel outside the full content single.php, page.php. So insert function over this


Here ------

the_content()


Thank you





Appending parameters to WordPress query string in backend


I'm creating a plugin that is using the add_menu_page function to create a page for my plugin options. This means that the url for my plugins main options page is like this


http://localhost:8888/my-website/wp-admin/admin.php?page=my-wordpress-plugin


Now, in my plugin options page there is a standard form with a drop down menu that lets people choose what data they want to display.



<form>
<select name="data-to-get">
<option value="1">Foo</option>
<option value="2">Bar</option>
</select>
<input type="submit" value="get-data">
</form>


Currently, when you select an option and click the button you are taken to this url:


http://localhost:8888/my-website/wp-admin/admin.php?data-to-get=1


This ends up loading a new page which is just blank. What I want to happen is this:


http://localhost:8888/my-website/wp-admin/admin.php?page=my-wordpress-plugin&data-to-get=1


I know that WordPress has a built in function add_query_arg so I need to do something like this:



add_query_arg( 'data-to-get', '1', 'http://localhost:8888/LFB/wp-admin/admin.php?page=lfb-player-stats' );


However, where I'm stuck is that I don't know how to hook this in. It needs to be inserted after the select value has been chosen and when the get request from the form is sent.





Where can I always find the price of a plugin


I'm surprised that this question hasn't already been addressed, but I've noticed that all to often, when I view a plugin's page, and they have a free vs. "PRO" version, the price is not displayed anywhere. I go through all the tabs (which is time-consuming enough), I check the FAQ, Support, etc., but nowhere is the price listed.


I don't have time to first install a plugin and then find out what kind of functionality I'm missing out on, and then finally get to the bottom line. Does anyone else notice this problem? Or am I missing something simple in regard to finding out how much a plugin costs? I'd really like to see the price right away so I can decide if it's worth it to investigate the plugin.





Using two permalinks for one post


Using two permalinks for one post


I am developing a wordpress website for a client, the client want to show 2 separate templaes for post details the scenario will be.


user clicks on post and our default single.php will load up, there have a play button when user click on play button then instead of post name in permalink I want to add /play/post-name and need to load second template for that.


searched on internet and found some suggestions like Maintaining two permalink structures and https://wordpress.org/support/topic/multiple-posts-in-1-permalink but these are not working and also these are trying to add at the end of the link but i need it to before post-name


any help will be appreciated.


thanks


Actually this is a game website and from posts listing page when user click on game image he will see a single page with game description and a play button when user click on play button he can then move to the actual game, so the post is same but we need seperate link for details and play pages.


thanks





wordpress pages/post slow, hangs and white text


wp version 4.1


I cant figure out what went wrong, didnt change or updated plugins. The only thing i can think of that is different before i had this problem that i inserted 5000 pages with wp_insert_post. (i dont often edit pages).


I insert all those pages as "normale" page.


errors: (half loaded edit page) white text (shown in console chrome) /wp-admin/post.php?post=15195&action=edit Failed to load resource: the server responded with a status of 500 (Internal Server Error) Uncaught ReferenceError: switchEditors is not defined (after clicking text)


whats going on here, anyone idea?





How to show WordPress Parent and child category different PAge?


I am currently trying to do a directory style site, and I currently have parent categories and child categories. Right now I have the parent categories showing and when you click on the parent it shows the child categories. Problem is now, I can't figure out how to display all the material in the child categories when you click on the child categories. Is there a conditional statement or a way that I can have the child categories go to the archive.php so it can display something else. Right now parent and the child categories pull from the category.php, so they end up being the same page.





Upload Multiple Files With Multiple Fields And With media_handle_upload


I asked this question about few days ago and the answer solved my instantly problem but now when I tried to put many file fields in the form just the first field work because the solution of my previous question overwrite the $_FILES array.


Now I have the following HTML in my form:



<input type="file" name="my_file_upload[]" id="my_file_upload[]" multiple="multiple">
<input type="file" name="my_file_uploadone" id="my_file_uploadone">
<input type="file" name="my_file_uploadtwo[]" id="my_file_uploadtwo[]" multiple="multiple">


How can upload these files using media_handle_upload?


Any help will be appreciated.





Enqueue core jQuery in the footer?


I have this in my functions.php file and I can't get jQuery to load in the footer. The includes file loads in the footer fine, though. What else do I need to do?



function starter_scripts() {
wp_enqueue_style( 'starter-style', get_stylesheet_uri() );

wp_enqueue_script( 'jquery', '', '', '', true );

wp_enqueue_script( 'includes', get_template_directory_uri() . '/js/min/includes.min.js', '', '', true );
}
add_action( 'wp_enqueue_scripts', 'starter_scripts' );




wc_print_notices() does not display message on live server


I have a custom signin page template which using wc_print_notices() (along with woocommerce installed, of course) to display the error message when there is fail logged in.


It is working fine in my local computer development environment, I can see the error messages displayed when there is failed log in by the user. The problem is, when I tested it on the live server, the error message does not displayed. However, I can see the Dom displayed for the error message.



<ul class="woocommerce-error">
<li></li>//no message displayed in this
</ul>


Seem it can detect the errors, but can't display the text. I tried turning the debug mode on, but there is no errors show. So I guess, may be this has something to do with the server setting?? Any idea?





Woocommerce- Show upsells in order received page [on hold]


I am trying to show the upsell products in the order received page. (thank you page after the order is placed)


I have managed to get the product id on that page, however i am unable to get the upsell ids from that product id.


Here is what I tried to use.



$items = $order->get_items();

foreach ( $items as $item ) {
$product_id = $item['product_id'];
}

echo $product_id;

$product = new WC_Product($product_id);
$upsells = $product->get_upsells();
if (!$upsells)
return;

$meta_query = WC()->query->get_meta_query();

$args = array(
'post_type' => 'product',
'ignore_sticky_posts' => 1,
'no_found_rows' => 1,
'posts_per_page' => $posts_per_page,
'orderby' => $orderby,
'post__in' => $upsells,
'post__not_in' => array($product->id),
'meta_query' => $meta_query
);

$products = new WP_Query($args);
if ( $products->have_posts() ) : ?>

<div class="upsells products">

<h2><?php _e( 'You may also like&hellip;', 'woocommerce' ) ?></h2>

<?php woocommerce_product_loop_start(); ?>

<?php while ( $products->have_posts() ) : $products->the_post(); ?>

<?php wc_get_template_part( 'content', 'product' ); ?>

<?php endwhile; // end of the loop. ?>

<?php woocommerce_product_loop_end(); ?>

</div>

<?php endif; ?>


There is always only ONE product in the cart and not many products.


The above loop doesn't display anything at all. WP_Debug is true, still no error !


Any help is appreciated.





401 error persists despite repeated attempts to solve this


The website in question is http://www.empsolutions.ca.


Was running fine up until a few hours ago, when users trying to access /wp-admin are redirected to the 401 Authorization required page. The site itself is running fine and the email servers are running fine.


Here's what I've tried:


Disabled Wordfence plugin Disabled all plugins Created new user in database (no use since can't even get to login screen) Spoken to hosting provider to determine no IPs of mine were blocked Deleted .htaccess file Renamed child theme


None of these things have worked... grateful for any suggestions.





db.php, is it a legit file


On one of a WP installation i troubleshoot (because site is down, too much DB connection) for, there is a ADDED file at the root (with wp-config.php and other) this file is called : db.php


It's 280 KB in size and contain some cheezy data, here is a sample


Usuage google search dont reveal it's a hack, but does not reveal it's a LEGIT wp file anyway... so the question is, what i do with it...


sorry for the "garbage look" but it's as this in the file.... i am worry !



<?php
/** Adminer - Compact database management
* @link http://www.adminer.org/
* @author Jakub Vrana, http://www.vrana.cz/
* @copyright 2007 Jakub Vrana
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
* @version 4.1.0
*/error_reporting(6135);$Ec=!preg_match('~^(unsafe_raw)?$~',ini_get("filter.default"));if($Ec||ini_get("filter.default_flags")){foreach(array('_GET','_POST','_COOKIE','_SERVER')as$X){$_h=filter_input_array(constant("INPUT$X"),FILTER_UNSAFE_RAW);if($_h)$$X=$_h;}}if(function_exists("mb_internal_encoding"))mb_internal_encoding("8bit");if(isset($_GET["file"])){if($_SERVER["HTTP_IF_MODIFIED_SINCE"]){header("HTTP/1.1 304 Not Modified");exit;}header("Expires: ".gmdate("D, d M Y H:i:s",time()+365*24*60*60)." GMT");header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");if($_GET["file"]=="favicon.ico"){header("Content-Type: image/x-icon");echo
lzw_decompress("\0\0\0` \0�\0\n @\0�C��\"\0`E�Q����?�tvM'�Jd�d\\�b0\0�\"��fӈ��s5����A�XPaJ�0���8�#R�T��z`�#.��c�X��Ȁ?�-\0�Im?�.�M��\0ȯ(̉��/(%�\0");}elseif($_GET["file"]=="default.css"){header("Content-Type: text/css; charset=utf-8");echo
lzw_decompress("\n1̇�ٌ�l7��B1�4vb0��fs���n2B�ѱ٘�n:�#(�b.\rDc)��a7E����l�ñ��i1̎s���-4��f� ��i7������Fé�vt2���!�r0���t~�U�'3M��W�B�'c�P�:6T\rc�A�zr_�WK�\r-�VNFS%~�c���&�\\^�r����u�ŎÞ�ً4'7k����Q��h�'g\rFB\ryT7SS�P�1=ǤcI��:�d��m>�S8L�J��t.M��� ϋ`'C����889�� �Q����2�#8А����6m����j��h�<�����9/��:�J�)ʂ�\0d>!\0Z��v�n��o(���k�7��s��>��!�R\"*nS�\0@P\"��(�#[���@g�o���zn�9k�8�n���1�I*��=�n������0�c(�;�à��!���*c��>Ύ�E7D�LJ��1�J=���1L��?�s=#`�3\$4���uȱ��zG�C YAt�?;�Q�k&��YP�u��ǯ}UaHV%G;�s��<A\0\\��P�\\��&ª�V��\n�SU�t���r���2� l^�Z6�ej����A�d�[�sն�JP����ҝ��8�=����6#˂74*���#e���!�7{�6��<o�C�9v[�M��-`��k�>�l�ڴ��I��H�3�x����w0t6��%MR%��jh�B�<�\0�AQ<P<:��u/�;\\>��-��ʈ��QH\nv�L+v�æ�<�\r��v����\\*����Ӵݢg��n˩��TЩ2P�\r��ߋ\"+z�8���:#�����2��J[�i����;z����r�3#�ى�:�n�\r㽃e�pdݍ� �2c��4�k���\rG��E6_����މb��/��HB%�0�>���hoW�nxl֍�浃CQ^�������\r����4lK{�Z��:���Ã�.�p��Ă�J�B-�+B���(�T�%��J�0�l�T�`+�-��@B��ۄV��\0��C�,�0t��F���?Ġ�\na@Ɍ>��ZEC��O�-���^Q�&���)I)�����R�]\r��9�7_��\r�F80�Ob� ���>���\nR�_��8��٫�ov0�bCA�F!�t��ă%0�/�zAYO(4������ '�] I��8hH�05�3�@x&n��|T���)`�.�s6eY�D�z�����Jѓ�.��{GEb��Ӌ����2��{\$**��@�C��-:zYHZI��5F]��Y��C�O�A����`x'�.*9t'{�(�wP����=�*���*�xwr��*c���c|�D���V��\r�V.�0���V�d�?Ҁ��,E͝`T��6ۈ-����ڎT[ѐ�z��.Ar��̀P��n�c=a�9F�n�!�u��A���0iP��J6e�T]V�[\rX��a��v�k�\n+E���ܕ*\0�~���@g\"�NCI\$��Ɍ���x@W�y�*vuD�\0�v�댆V\0�V`G�u�E�֕��f�l�h�@�)0@�T��7���§RA�ٷ�3ۘ��/Q�]�,s�{VR�����F���A��<�vץ�%@9��F��5t�%�+�/�8;�W����J��o:�N�`� ����h��{ܣ�� �Ԑ8�Eu�&�W|Ɇ���U�&\r\"����|-udž�N��:nc��fV����#U20�>\"���>�`�k]�-��x�S�͇Т����c��B��}�&`��r+E��\$�yN���b,���Wx ��-9��r�,��`�+���ˊ��C��)��7�x\r��W�fM�SR�\\�z��Q�̓��uA���2���4�L&�Hi µ���S\$)e���g rȌ��\$]Z�iYs���kW�n>�7E1k8�d�r�k����E���w�wcm�Ty����a�\$tx\rB��=����*�<���l�f�K��N/��� �l���kH��8�.���?f�����6�ч�{gi/\"�@��K��@2��a|#,Z��� ��w�d�������6w�^&��t��P�����]���.����T��kro����\ro=�%��h`:\0᱂����|ꊣ�a�Ԯ6*:��*��rO-^����n���M�}���Aya���\n�u^��rnO\r���`�T~</�w�y�}�:�|�����̡6������v�\rc<�b#����\$�s��|燇V)�h�TC��(Ľ���]6��1�!1M��@a�/�`�>ٸ�ߣ�����C/�6ഷ#p@p���`Z���ch��\0��\0o��4O�O�i\0-\n���/�\0�D�.� ���.�Đ\0fi��ȫ���\0��ID��\0��\r��0f��o�����G����eJ|\r���l �3�~�iP��&���/�\0�9 ^\0r�0]�� �o��.�\"� ���M���v�P�Z��mp�P���ڜ�ޏ���{��C?��k��ϼ}��d��ʏ�~=�.��- � �m1>h���Е1;QI�OP�\r��c�pApV�k\rQ*�Q}���q>��u�15�BqQ[1f��l���ap���\0��*�J�Q=�����G��������_��b�GHF.�0�� = 2P��������P!�#(3 \n�!1&72f��`�/��\0��\"P�U�\$�\r0��,QrU&2f��_�X���]�9\"�S'�'�y�8\r����kW)O�)��*Ra%�\\i�%�&ҳ+r��3�S`�,�v��&2�L�&Pu*��-�0\"�%HĬԞ��@ؓ��H�B�P(��\$p&�,1M� �ح��;\rn�.�� I�.�',1�)�4���2�u+�3� `�S��pL\nt��_*�S3;6r�'h35�55䜋d2q+6�8�O7sC\"pm8ҭ��6��9�m\n@e0�<8B�8�<,(���8��\0� �0�J�<@��I���R6pԭmG�\"11�6��.\"����5̂��:��8b�A1�;�';�?<*\$�,�̍o= �T��/3�#��҆�");}elseif($_GET["file"]=="functions.js"){header("Content-Type: text/javascript; charset=utf-8");echo
lzw_decompress("f:��gCI��\n0��S��a9��S`�����&�(��n0���QI��f��\$�At^ s�G��tf6e��y��()L�S��P'�����R'�fq]\"�s> )�`�H2�Eq9��?�*)��t'��ϧ�\n \r�s<�Pi2IN��*(=2�gX��.3�N�Y4�B<�L���i�̥2��z=�0H���'�ꌚ�u�tt:������e�]`pX9��o5�g��I��,2O4��х�M�S�(�a��#������|�G�b���x�^Z[��G��uTv�(ҝm@V�(���bN<��`��X�1�+��9J8�2\r�K�9�h� ���


[...] there is a lot more in the file, it's just the first page or so !





Deeper editing of index.php and single.php


I'd like to fully customize the CSS and HTML of the main blog page (index.php) and the individual post page (single.php). However, looking in index.php and single.php, I don't see how to get at the HTML/CSS I'm looking for, as it appears to be doing this with external PHP functions.


As an example, I'd like to have my index.html page have something like this for the most recent two or three posts:



<div class="post_summary">
<img src="post_image1.png" class="post_image"/>
<h1>Name of first post</h1>
<p class="post_date">December 29th, 2014</p>
<a href="first_post.html">Read more...</a>
</div>


Presumably, this will involve a PHP loop and pulling the featured image, name, and date of each post. Any pointers on how to approach this would be terrific! Thanks for reading.





Querying A Post That Includes Two Taxonomies Using JSON Rest API


I'm using the JSON Rest API plugin (https://wordpress.org/plugins/json-rest-api/). I have two custom taxonomies with one term each:



  1. Inner Part Categories

    • Eye



  2. Symptoms Categories (Man)

    • Broken Bone Single Fracture




I need to show posts that match both of these categories and terms. I've tried the following:



http://mcsc.hawkhorne.com/wp-json/posts?type=male-conditions&filter[taxonomy]=inner-part-categories&filter[term]=Eye&filter[taxonomy]=symptoms-categories-man&filter[term]=Broken%20Bone%20Single%20Fracture


But this method only returns the posts under the last declared taxonomy and term. For example, if I switch the tax and term around as such:



http://mcsc.hawkhorne.com/wp-json/posts?type=male-conditions&filter[taxonomy]=symptoms-categories-man&filter[term]=Broken%20Bone%20Single%20Fracture&filter[taxonomy]=inner-part-categories&filter[term]=Eye


It will then only show posts under the tax inner-part-categories and term Eye and ignore the first tax and term query.


I've been searching for hours and having found a solution.


I was also thinking maybe an array of sorts could be passed in the ajax data request, sort of how it's done in WP Query. I have the following code:



data: { filter: { 'posts_per_page': -1, 'post_status': 'publish', 'orderby': 'title', 'order': 'ASC' } },



Thanks for your help.





How to customize Woocommerce is_sold_individually() notice [on hold]


line 925 of includes/class-wc-cart.php is:



// Downloadable/virtual qty check
if ( $product_data->is_sold_individually() ) {
$in_cart_quantity = $cart_item_key ? $this->cart_contents[ $cart_item_key ]['quantity'] : 0;
// If it's greater than 0, it's already in the cart
if ( $in_cart_quantity > 0 ) {
wc_add_notice( sprintf(
'<a href="%s" class="button wc-forward">%s</a> %s',
$this->get_cart_url(),
__( 'View Cart', 'woocommerce' ),
sprintf( __( 'You cannot add another &quot;%s&quot; to your cart.', 'woocommerce' ), $product_data->get_title() )
), 'error' );
return false;
}
}


Obviously I don't want to edit that file, but I need to customize the message. Been googling for hours and can't find an easy solve. I have been looking for a filter or function to modify.


What I want is a method to modify this from functions.php or a pluggable function.


Any help us very much appreciated.





A shortcode with a paragraph


Does anyone know how to wrap a paragragh tag around a wordpress shortcode.


The shortcode is a default worpress shortcode: [video src="......"]


I think it says something about it here: http://codex.wordpress.org/Shortcode_API#Output


Any help appreciated.





With over a page of content the footer remains where the bottom of the screen was at top scroll


I've been building an artist website to promote my music and I've ran into an obstacle with my footer. What I want is very simple (or so it would seem). I'm trying to create a footer that sits under the content/body and is at the very bottom of the site. No white space on the left, right, or bottom. Then when the site has minimal content the footer will sit at the bottom of the screen. The problem that I'm running into is that when the content is more than a page long, instead of pushing the footer down with it, the footer just sits where the bottom of the screen is (when scrolled to the top). This means that when the user scrolls to the bottom of the site, the footer remains in the middle somewhere, overlapping content.


I wish I had kept track of all the sites and forums I've been on and tried, but It's been several full days of searching. It's better than when it started (originally I couldn't push the left and right margins to full width), but this last problem is just evading me. Any help would be very much appreciated. (I am using a Wordpress Twenty-Twelve Child Theme if that helps)


Undesired Footer


Desired Footer


My current hypotheses are as follows:




  1. There is code somewhere that makes the footer stick to the bottom of the screen with minimal content, and it is constantly applied. From what I understand, the way people do this is by using min-height:100%, but with/without that line it makes no difference.




  2. Maybe there is something not right in terms of my html hierarchy? Twenty-twelve used #masthead, #page, #main, and #colophon. I've come across a couple sites where people say to make sure the footer is outside of the main wrapper. I've done this but it hasn't worked.




  3. Maybe the issue is not in footer at all? Maybe the other containers need to be changed. Maybe #main needs to be set to position:relative; or something (but that hasn't worked).




Here's all the html:



<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<header id="masthead" class="site-header" role="banner">

<nav id="site-navigation" class="main-navigation" role="navigation">
<button class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></button>
<a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
</nav><!-- #site-navigation -->
<?php if ( get_header_image() ) : ?>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php header_image(); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /></a>
<?php endif; ?>

</header><!-- #masthead -->

<div id="main" class="wrapper">

</div><!-- #page -->
</div><!-- #main .wrapper -->
<footer id="colophon" role="contentinfo">
</footer><!-- #colophon -->
<?php wp_footer(); ?>

</body>
</html>


And here's the footer css:



footer {
background:url(http://kjel.ca/wp-content/uploads/2014/12/footer-img.jpeg) repeat-x bottom center;
height:100%;
width:100%;
position:absolute;
margin:0px;
padding:0px;
bottom:0px;
min-width:100%;
}


Also note that I have tried Ryan Fait's sticky footer which I've seen referenced quite a bit. I haven't been able to get it to work properly. I'm not a professional coder, I'm a musician with a basic knowledge of html and css trying to save cash. If I'm going about the footer the complete wrong way, feel free to set me straight. Any help is most appreciated! Oh and here's my site: www.kjel.ca





How to add wechat (weixin) link to navigation menu?


The profile link of WeChat (or Weixin) has the following format: weixin://contacts/profile/username


As you can see, it doesn't use http:// and that seems to be the reason that it cannot be added to the WordPress navigation menu.


Well you can add it, but after saving the menu, the URL field is blank (again).


The strangest thing is that the navigation menu does not exclusively save http(s); I just tried to save a telephone number URL (tel:00861012345678) and that is actually saved.


Is there any way to get the WeChat link to properly show?


Thanks.





Where like querry not working as expected


I have the following querry:



$results=$facilities=$mydb->get_results("SELECT facility_name from facility where facility_name like '%".$facility_name."%' LIMIT 0, 10");


It is not working as using regardless of whatever is typed as the facility name. It is just returning top 10.





How to redirect all pages of a custom post type


Here's the deal. Let's say I have a custom post type called "subscriptions". Under this post type there are pages like the following:



  • http://mysite.com/subscription/my-first-subscription

  • http://mysite.com/subscription/my-second-subscription

  • http://mysite.com/subscription/my-third-subscription


The issue is that I actually have a pricing page which allows users to use a widget to select the different subscriptions. I don't want the users to ever be able to access the subscription pages directly, even if they know the URL. My first thought is that I'd like any attempt to access a page of "subscription" type to be redirected to the pricing page. How would I do that?


(If someone has a better idea, I'm open to that as well.)





How do I get jQuery to Load before Bootstrap?


I am building a Bootstrap / WordPress site and I am having an issue with bootstrap.min.js loading before jquery, which results in issues like the navigation not working correctly.


Here is how I have the scripts enqueued.



function turtles_scripts() {
wp_enqueue_style( 'turtles-bootstrap-min', get_template_directory_uri() . '/css/bootstrap.min.css', array(), null, 'all' );
wp_enqueue_style( 'turtles-style', get_stylesheet_uri() );

wp_enqueue_script( 'turtles-bootstap-min-js', get_template_directory_uri() . '/js/bootstrap.min.js', array(), 'null', true );
wp_enqueue_script( 'turtles-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true );
wp_enqueue_script( 'turtles-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );

if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'turtles_scripts' );


However, when I look at the page source. The Bootstrap is loading before jQuery:



<script type='text/javascript' src='http://turtles.opteradev.com/wp-content/themes/turtles/js/bootstrap.min.js?ver=null'></script>
<script type='text/javascript' src='http://turtles.opteradev.com/wp-content/themes/turtles/js/navigation.js?ver=20120206'></script>
<script type='text/javascript' src='http://turtles.opteradev.com/wp-content/themes/turtles/js/skip-link-focus-fix.js?ver=20130115'></script>
<script type='text/javascript' src='http://turtles.opteradev.com/wp-includes/js/jquery/jquery.js?ver=1.11.1'></script>
<script type='text/javascript' src='http://turtles.opteradev.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'></script>
<script type='text/javascript' src='http://turtles.opteradev.com/wp-content/plugins/ml-slider/assets/sliders/flexslider/jquery.flexslider-min.js?ver=3.2.1'></script>
<script type='text/javascript' src='http://turtles.opteradev.com/wp-content/plugins/ml-slider-pro/assets/public.js?ver=2.5.1'></script>
<script type='text/javascript' src='http://turtles.opteradev.com/wp-content/plugins/eventON/assets/js/jquery.mobile.min.js?ver=1'></script>




Can users signup via the new REST API


I am building a mobile app that is a companion to a Wordpress site and will be retrieving and submitting data via a WP plugin built using the new REST API.


Users will need to be able to create accounts via the mobile app using either an email address or a Facebook account. Is this currently supported? I don't see anything the documentation about it.


Thanks.





How to get private property in parent class into extended class?


I am not sure if my function is firing before another funciton or if I am having issues with the $this variable when I am extending my class.


I am creating a function in my functions.php file. Here's a link to my function.


The specific function is extending a class that is an extension for WooCommerce. The template page calls the function like so:



<?php
$ssi_woocommerce_variation_control_output = new SSi_WC_Swatch_Picker( $product->id, $attributes, $variation_params['selected_attributes'] );
print_r($ssi_woocommerce_variation_control_output);
$ssi_woocommerce_variation_control_output->picker();
?>


The print_r output will produce the array content to the page. However I get this:



Start the Loop

Notice: Undefined property: SSi_WC_Swatch_Picker::$attributes in /my_url/wp-content/themes/my-theme/functions.php on line 13

Warning: Invalid argument supplied for foreach() in /my_url/wp-content/themes/my-theme/functions.php on line 13

End the Loop




UPDATE Good news (at least for me) the developer of the original class is going to change the private properties to protected and then I can access them without issue.





Add meta value to custom post type on publish


I have a client who is requesting that all posts of a certain custom post type (called 'custom-jobs') be set to automatically be included in the sitemap in the Yoast SEO plugin.


I found that in order to do this, the post needs a meta key of '_yoast_wpseo_sitemap-include' with a value of 'always'. So I attempted to call a function using the {status}_{post_type} hook as follows:



function on_jobs_publish( $post_ID ) {
global $wpdb;
$wpdb->insert(
'iCrewzWp_postmeta',
array(
'post_id' => $post->ID,
'meta_key' => '_yoast_wpseo_sitemap-include',
'meta_value' => 'always'
),
array(
'%d',
'%s',
'%s'
)
);
}
add_action( 'publish_custom-jobs', 'on_jobs_publish', 10, 1 );


This almost works. It adds the meta info to the DB, but the post_id is always set to 0. I've tried passing and using $post and $ID variables as well with no luck. Any idea how I can pass the custom post's id into this function so the meta info is associated with the post that was published?





Network installation giving errors when viewing or adding a user


I have just installed a fresh version of WP which I have turned in to a network install (using the instructions found here).


All seemed to be going well, and I was able to add a new site successfully, however I am experiencing issues with listing/adding users.


When I click on the Users menu item the list table gives the following warning -



Warning: array_keys() expects parameter 1 to be array, boolean given in {my-dir}\wp-admin\includes\class-wp-users-list-table.php on line 307



This line is - $editable_roles = array_keys( get_editable_roles() ); - the issue is that get_editable_roles() is ruturning false.


The same problem also occurs when I try to add a user, although the warning is at a different location -



Warning: array_reverse() expects parameter 1 to be array, boolean given in {my-dir}\wp-admin\includes\template.php on line 843



I've tried the obvious, deactivating all plugins (I'd added one) and switching to the default theme, but the warnings still remain.


Can anybody please suggest how I may fix this problem?





Wordpress Custom Widget Strange Behaviour


I have developed a Custom widget plugin with a dozen of input fields. Some of those input fields load Fabtastic Color Picker. When I add the widget in any widget area, the color picker loads very slow. But after clicking on the SAVE button, the fields load without any delay ...


Is this a bug in wordpress widgets or in my plugin?





how to give custom message to user when create a post in wordpress


I am trying to make a custom message instead of the default message when user post a add in ClassiPress Theme , does anybody know how to do it!


i'm trying below code, but it not working



add_filter('transition_post_status', 'notify_status',10,3);


function notify_status($new_status, $old_status, $post) {
global $post;
if ($new_status == 'trash')
{
$pstatus = $new_status ;
$message= 'admin blocked ur post';

return $message;
}
}




Add yoast seo breadcrumbs categories title [on hold]


i'm add code <?php if ( function_exists('yoast_breadcrumb') ) { yoast_breadcrumb('<p id="breadcrumbs">','</p>'); } ?>


and have code breadcrumbs:


<div class="breadcrumbs"> <span prefix="v: http://rdf.data-vocabulary.org/#"> <span typeof="v:Breadcrumb"><a href="http://www.luatvietan" rel="v:url" property="v:title">Trang chủ</a></span> » <span typeof="v:Breadcrumb"><a href="http://www.luatvietan/tu-van-phap-luat/" rel="v:url" property="v:title">Tư vấn pháp luật</a></span> » <span typeof="v:Breadcrumb"><a href="http://www.luatvietan/tu-van-doanh-nghiep/" rel="v:url" property="v:title">Tư vấn doanh nghiệp</a></span> » <span typeof="v:Breadcrumb"><span class="breadcrumb_last" property="v:title">Thành lập doanh nghiệp</span></span> </span></div>


How to add title to category as


<span typeof="v:Breadcrumb"><a href="http://www.luatvietan/tu-van-doanh-nghiep/" title="Tư vấn doanh nghiệp" rel="v:url" property="v:title">Tư vấn doanh nghiệp</a></span>


Thanks





lundi 29 décembre 2014

do_action filter function from add_action array


I am looking at the following setup:




-- Combing multiple functions into single action --
add_action( 'single_post_meta_start', array( $this, 'the_title' ), 10 );
add_action( 'single_post_meta_start', array( $this, 'the_author' ), 20 );
add_action( 'single_post_meta_start', array( $this, 'the_category' ), 30 );

-- Combine single_post_meta_xxx into single function --
public function single_job_listing_meta() {
do_action( 'single_job_listing_meta_start' );
do_action( 'single_job_listing_meta_end' );
do_action( 'single_job_listing_meta_after' );
}


Is it possible to filter the action to only retrieve back the function 'the_category' and the other function codes will not pass through to the front end?


Thanks.





Custom widget doesn't save values from dropdown box


I am trying to save the value from a dropdown box on a custom widget created by me. the title from the same widget is getting saved, but not the values from drop down box. Can someone please help me? Here is the code:



<?php // Creating the widget
class rspwidget extends WP_Widget {

function __construct() {
parent::__construct(
// Base ID of your widget
'rspwidget',

// Widget name will appear in UI
__('RSP Ad Widget', 'rspwidget_ad'),

// Widget description
array( 'description' => __( 'Revenue share Plugin(RSP) Widget', 'rspwidget_ad' ), )
);
}

// Creating widget front-end
// This is where the action happens
public function widget( $args, $instance ) {
echo $args['before_widget'];
if ( ! empty( $instance['title'] ) ) {
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];
}
// before and after widget arguments are defined by themes

// This is where you run the code and display the output
//echo __( 'Hello, World!', 'rspwidget_ad' );
echo adsensewidgetad();
echo $args['after_widget'];
}

// Widget Backend
public function form( $instance ) {
$title = ! empty( $instance['title'] ) ? $instance['title'] : __( '', 'rspwidget_ad' );
$widgetads = ! empty( $instance['$widgetads'] ) ? $instance['$widgetads'] : __( '', 'rspwidget_ad' );
// Widget admin form
?>
<p>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />

<label for="<?php echo $this->get_field_id( 'widgetads' ); ?>"><?php _e( 'Ad dimensions:', 'widgetads' ); ?></label>
<select id="<?php echo $this->get_field_id( 'widgetads' ); ?>" name="<?php echo $this->get_field_name( 'widgetads' ); ?>" type="text">
<option value="300x250">300x250px</option>
<option value="336x280">336x280px</option>
<option value="300x600">300x600px</option>
<option value="320x100">320x100px</option>
</select>
</p>
<?php
}

// Updating widget replacing old instances with new
public function update( $new_instance, $old_instance ) {
$instance = array();
//$instance = $old_instance;
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
$instance['widgetads'] = ( ! empty( $new_instance['widgetads'] ) ) ? strip_tags( $new_instance['widgetads'] ) : '';
return $instance;
}
} // Class rspwidget ends here

//create the ad for the widget
function adsensewidgetad() {
$options = get_option('RSP_options');
if (!get_option('RSP_options')) {
return 'Configure RSP settings!';
}
$position = '';
if (array_key_exists('radio_option1', $options)) {
$position = $options['radio_option1'];
}
/*if (array_key_exists('radio_option2', $options)) {
$position = $options['radio_option2'];
}
if (array_key_exists('radio_option3', $options)) {
$position = $options['radio_option3'];
}*/
if(get_the_author_meta( 'RSP_text_string' )){
$input = array($options['RSP_text_string'], get_the_author_meta( 'RSP_text_string' ));
} else {
$input = array($options['RSP_text_string']);
}
shuffle($input);

if ($input[0] == 'pub-0000') {
return 'Configure PUB ID!';
}
$ad_content = '<div align=center><script type="text/javascript"><!--
google_ad_client = "ca-'.$input[0].'";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div>';
if($position == 'Top') {
return $ad_content.'<br />'.$content;
}
if($position == 'Bottom') {
return $content.'<br />'.$ad_content;
}
if($position == 'Middle') {
$count_words = strlen($content)/2;
$insert_ad = strpos($content, '. ', $count_words);
$ad_content = '<br />'.$ad_content.'<br />';
return substr_replace($content, $ad_content, $insert_ad+2, 0);
}
return $ad_content;
}

// Register and load the widget
function rsp_load_widget() {
register_widget( 'rspwidget' );
}
add_action( 'widgets_init', 'rsp_load_widget' );
?>




Using wp_localize_script to store the template url into a variable to use in JS


I was trying to store the template url (bloginfo(template_url);) into a variable so I could use it in my JavaScript. However, I realized this wasn't possible and someone alerted me to wp_localize_script and said that it could do what I wanted. I looked through the codex but I'm still unsure as to how to implement this.


Here's what I have so far:


Function



function starter_scripts() {

wp_enqueue_script( 'jquery' );

wp_localize_script( 'my_script', 'templateUrl', array(
'templateUrl' => template_url()
) );
}
add_action( 'wp_enqueue_scripts', 'starter_scripts' );


JS



jQuery(document).ready(function($){

// Fade in Contact background
$('body.page-template-page-contact #content').css('background', 'url(templateUrl + bg-contact.jpg) 50% 0% no-repeat fixed').fadeIn(2000);

});


Where have I gone wrong?





Looking for a gallery plugin with specific features


I am looking for an inline gallery plugin where each slide registers as a new page view.


This website has a gallery with the exact behaviour I want:


http://www.streetmachine.com.au/news/1412/gallery-shelby-gt350/


The gallery slides also preload the images too. Does such a plugin exist for Wordpress?


Many Thanks.





Missing domain http://./wp-… in redirects


I am migrating my WP website from staging to production and I have a problem with Dashboard access.


When I try to access



http://<domain>/wp-admin.php


it redirects me to



http://./wp-login.php?redirect_to=http%3A%2F%2F<domain>%2Fwp-admin%2F&reauth=1


I can login with going directly to http://<domain>/wp-login.php and I can go to any Dashboard page but cannot change anything (with Save button) without redirecting to http://./wp-admin/….


For example, if I want to change post content,



  1. I do it and hit Save button.

  2. Then I redirects to http://./wp-admin/post.php?post=20&action=edit&message=1.

  3. Then I go back and see that post changes are saved.


The same problem is with changing Permalinks settings.


So what is broken: there is a dot . instead of my domain in redirect URIs.


Maybe it is because of cyrillic одиссейдом.рф domain?


Have I add some rewrite rules to fix it?




UPD:


I saved a page, go back, save again and there is no problem.


Then I tried to change site title in Settings/General and there is no problem too.


Then I tried to turn off Emoticons in Settings/Writing and there is no problem.


But activating/deactivating a plugin goes with problem.


I have no idea, my friends.





images invisible in wordpress after migration


I have migrated my word press site to host gator with same domain name but now i am facing a big problem. All the images in the site are invisible except header logo. Even i tried to upload a new image but it is not displaying. I have set the file permissions again but no change. Please help me out.





seo yoast custom post type XML url issue


I am using Custom post type and Seo yoast plug-in i have built in custom post type.Now the Seo Person wants different post type slug in Site map url of yoast.


But when i change slug using rewrite it does not reflect in XML site map and keeps the original post type name.What should i do?


Does the post type name in url affect seo?





Category as subdomain


I am new to wordpress


I need my categories as subdomains i,e. http://domain.com/category/post to http://category.domain.com/post


I have tried using wp-subdomains , subdomains, main category subdomains plugins but i have a problem , when accessing my site home page all icons (theme icons) are displaying perfectly, but when i access http://category.domain.com/post the images that i have included in post are displaying perfectly, but theme icons(fb icon.....,etc)are not displaying...


any help is greatly appreciated


My site: http://onmirror.net


Problem: http://sports.onmirror.net/fifa/





Appending parameters to WordPress query string in backend


I'm creating a plugin that is using the add_menu_page function to create a page for my plugin options. This means that the url for my plugins main options page is like this


http://localhost:8888/my-website/wp-admin/admin.php?page=my-wordpress-plugin


Now, in my plugin options page there is a standard form with a drop down menu that lets people choose what data they want to display.



<form>
<select name="data-to-get">
<option value="1">Foo</option>
<option value="2">Bar</option>
</select>
<input type="submit" value="get-data">
</form>


Currently, when you select an option and click the button you are taken to this url:


http://localhost:8888/my-website/wp-admin/admin.php?data-to-get=1


This ends up loading a new page which is just blank. What I want to happen is this:


http://localhost:8888/my-website/wp-admin/admin.php?page=my-wordpress-plugin&data-to-get=1


I know that WordPress has a built in function add_query_arg so I need to do something like this:



add_query_arg( 'data-to-get', '1', 'http://localhost:8888/LFB/wp-admin/admin.php?page=lfb-player-stats' );


However, where I'm stuck is that I don't know how to hook this in. It needs to be inserted after the select value has been chosen and when the get request from the form is sent.





using jQuery to find an href and print the domain name


I've got a site with hundreds of images that are linked to external websites.


I'm trying to work out a jQuery script that will find the hostname of the href link around each image and echo that domain name in a caption div below the image.


For instance, if an image is linked to http://amazon.com/someproducturl, I'd like to dynamically add a caption that says "Buy now from Amazon.com"





Sidebar Categories Questio


I added five categories through widgets on my primary sidebar. Under each of them, all of my main categories that have posts in them are coming up. However, I only want certain categories to come up in each of them, not all the categories that have posts. I attached an image of the issue. So under CSU Northridge, I only want the CSU Northridge General to come up while under SDSU, I only want the SDSU Ceneral to come up. Does anyone know how to fix this? Thank you.enter image description here





Call Multiple Sidebars at once


I have multiple sidebars registered for my site's footer, called footer-1, footer-2, and footer-3. It will be a 3 column layout in my footer. What is the best way to call these 3 sidebars? Should I check if all 3 is_active_sidebar() then register them? Or is there a better way to so so?





How to make a custom URL on the frontend using the POST slug to load a custom page?


I am wanting to make a plugin that will allow a user to go to a URL like this...


http://www.domain.com/post-title-here/stats


On this stats page is where I will have my plugin output stats data related to the post/page that it is associated with.


I need help with setting up the URL and the page to be shown at that URL. Any ideas?


One thing I saw that is close to what I want is Custom Endpoints however they seem to add


permalink/my-endpoint/endpoint-value/ where I would really need it to instead be like permalink/my-endpoint/ more specificially /page-name-slug/stats/





Removing entry header based on post format in Genesis theme


Working on a genesis child theme -- sixteen nine -- and I've turned on post formats. I'd like to remove the post title from the entry head section for certain formats -- aside, gallery, image, etc -- but can't seem to figure it out. This is where I started:



remove_action( 'genesis_entry_header','genesis_do_post_title' );
add_action( 'genesis_entry_header','post_format_post_title' );


function post_format_post_title() {

if ( has_post_format('aside') ) {
remove_action( 'genesis_entry_header','genesis_do_post_title' );
}}


That removes the title, but from every post regardless of format. Someone in another forum gave me this:



add_action( 'genesis_before_entry', 'possibly_remove_entry_header' );

function possibly_remove_entry_header()
{
//* get the post format
$post_format = get_post_format();

//* remove the entry header based on the post format
switch( $post_format )
{
case 'aside':

//* remove the entry header. See Genesis/lib/structure/post.php
remove_action( 'genesis_entry_header', 'genesis_do_post_format_image', 4 );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
break;

default:
break;
}
}


That did the same thing, removed all entry header content from all posts regardless of format.


Any thoughts on how to accomplish this? Thanks very much.





Widget is breaking on filter function


I have created a widget which displays posts based on Display Posts shortcode. All works fine till I have added filter to public function widget() to output titles only (and need to be executed only for that widget):



function display_posts_shortcode_clean_output( $output, $atts, $image, $title, $date, $excerpt, $inner_wrapper ) {
$output = $title;
return $output;
}
add_filter( 'display_posts_shortcode_output', 'display_posts_shortcode_clean_output', 10, 9 );


When I will use that widget on the page once all is OK. When twice, with different widget control option widget code is breaking on function display_posts_shortcode_clean_output.


Do I need to move



add_filter( 'display_posts_shortcode_output', 'display_posts_shortcode_clean_output', 10, 9 );


to function __construct() and then from public function widget() call apply_filters? But in that case where should display_posts_shortcode_clean_output() function go?


Any clue?





Single page archive - get coresponding taxonomy and terms


For custom post type i have 12 taxonomies (12 months) and each of them with many terms (plant parts - roots, leaves, flowers etc.) On archive page i retrieve a data list with this



foreach($months as $month) :
$args = array( 'post_type' => 'branje_biljaka', 'posts_per_page' => 100,
'tax_query' => array( array(
'taxonomy' => $month,
'field' => 'slug',
'terms' => $plant_parts
)
)
);
$branje = new WP_Query( $args );


and it works perfectly. On a single archive page I am stuck. I don't know how to fetch any corresponding data other than the_title() but I need to fetch the same data for every month and all plant parts but only for that specific post.


I dont have any 'normal' data to echo like the_content, only those terms. I think I am complicating this more than I should and I believe Wordpress does this with much less work... but how do I expand the same query so it grabs only current single archive post title? Everything else should be the same...


Inserting something like 'ID' => get_the_ID() into arguments does nothing.





WP_User_Query. Whats wrong with 'relation' => 'OR'


I want all the users who meet either Condition1 OR Condition2. Sort by last_name.


If I take condition1 AND condition2 ('relation' => 'AND'), the query is OK. If I take 'relation' => 'OR', I get all records and unsorted. What is wrong?



$args = array(
'meta_query' => array(
'relation' => 'OR',
0 => array(
'key' => 'user_thema1',
'value' => $kate_name,
'compare' => '='
),
1 => array(
'key' => 'user_thema2',
'value' => $kate_name,
'compare' => '='
)
),
'meta_key' => 'last_name',
'order' => 'ASC',
'orderby' => 'meta_value'
);
$user_query = new WP_User_Query( $args );




How to associate two custom fields together?


On my website you can purchase a trip after choosing the departure date (among the available departure dates). In the back-end, a trip is a CPT in which departure dates are specified through "Repeater Field" (an extension of "Advanced Custom Fields" plugin).


Trip price depends on departure date so each departure date must have a trip price attached to it. How can I have a price field next to each date field?





Wordpress version for this autocomplete jQuery code


The following code works well but does not work in wordpress please assist:



$(document).ready(function () {
var ac_config = {
source: "ajax.php",
select: function (event, ui) {
$("#facility_name").val(ui.item.facility_name);

},
minLength: 1
};
$("#facility_name").autocomplete(ac_config);


});


The problem is that the ajax.php is file is not being seen as the source. Can someone help with correctly declaring the source?





Why is wp_kses not keeping style attributes as expected?


Here is my php code:



$allowed_html = array(
'div' => array(
'title' => array(),
'class' => array(),
'style' => array()
)
);

$str = '<div title='Click to continue' style='display:table'>This is a button</div>';
wp_kses($str, $allowed_html );


I want to keep the style attribute. $str is just an example.


Thank you, MMK.





menu is only pulling in one item


I have an issue where wordpress is only pulling in one menu item on a client's website... it was pulling them all in just fine until recently, so I'm not sure what changed.


This is how the menu was pulling in earlier, and it still does, but now only pulls in the last menu item...



<?php
$args = array(
'menu_class' => 'sf-menu',
'menu' => 'navigation'
);
wp_nav_menu( $args );
?>


Does anyone know what could be causing this or how to fix it?


Thanks





Deeper editing of index.php and single.php


I'd like to fully customize the CSS and html of the main blog page (index.php) and the individual post page (single.php). However, looking in index.php and single.php, I don't see how to get at the actual code, as it's calling php functions I'm not familiar with.


As an example, I'd like to have my index.html page have something like this for the most recent two or three posts:



<div class="post_summary">
<img src="post_image1.png" class="post_image"/>
<h1>Name of first post</h1>
<p class="post_date">December 29th, 2014</p>
<a href="first_post.html">Read more...</a>
</div>


Presumably, this will involve a PHP loop and pulling the featured image, name, and date of each post. Any pointers would be terrific! Thanks for reading.





Override a theme function in a child theme?


Most if not all of the answers to this question are pretty old, or are for edge cases.


I have a child theme for a commercial theme ("Total"). The parent theme's functions.php loads functions from several php files in its "framework" folder. The function I am targeting is in fonts.php, called wpex_standard_fonts:



if ( ! function_exists( 'wpex_standard_fonts' ) ) {
function wpex_standard_fonts() {
return array(
"Arial, Helvetica, sans-serif",
"Arial Black, Gadget, sans-serif",
...
);
}
}


So, from what I have googled, I take this add to my child theme functions.php with my changes to it, right? So I add my custom font to the array.


But when I go to the admin tool, my custom font menu item is not there.


What did I miss here?





how to add js into wordpress theme


I am trying to create new WordPress theme from scratch. I have working html, css and js files. To add JS into wordpress theme I used:



function my_scripts_styles() {
wp_enqueue_script( 'easing', get_template_directory_uri() . '/js/easing.js', '2014-12-030', true );
}

add_action( 'wp_enqueue_scripts', 'my_scripts_styles' );


this code into function.php


As well as I tried using:



<script src="<?php get_template_directory_uri();?>/js/jquery.min.js"></script>


But it is not working...


What am I doing wrong / how can I add Javascript files to my theme?





Getting error while trying to use custom comment function


I'm trying to write a function that will allow me more control over the display of comments on a post page. However I'm confused about how to set it up so WordPress can use it. right now I get the following error:



Warning: call_user_func() expects parameter 1 to be a valid callback, function 'custom_comments()' not found or invalid function name in /Users/Brent/Desktop/Web Design/WP Playground/wordpress/wp-includes/comment-template.php on line 1711



Here is the call to the function:



<div class="comment-list">
<?php
wp_list_comments('type=comment&callback=custom_comments()');
?>
</div><!-- .comment-list -->


And here is what that section of my functions.php file looks like:



add_action('load_comments', 'custom_comments');

function custom_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
?>

<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">

<div class="comment-intro">
<em>commented on</em>
<a class="comment-permalink" href="<?php echo htmlspecialchars(get_comment_link($comment->comment_ID)) ?>"><?php printf(__('%1$s'), get_comment_date(), get_comment_time()) ?></a>
<em>by</em>
<?php printf(__('%s'), get_comment_author_link()) ?>
</div>

<?php if ($comment->comment_approved == '0') : ?>
<em><php _e('Your comment is awaiting moderation.') ?></em><br />
<?php endif; ?>

<?php comment_text(); ?>

<div class="reply">
<?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>

<?php } ?>


Could anyone tell me what I'm doing wrong here to get this error? I know from my research on this issue that sometimes you need to remove_action from another function that may be conflicting with this function, but I'm not even sure I'm calling this function correctly. Please help, I'm having a hard time finding good resources on how to use a custom comment function.


This is the only good resource I've found so I've been following this but it doesn't say anything about the errors: Custom Comments HTML Output


When I googled the error I found this page slightly helpful, but I haven't been able to identify the culprit function: wordpress.org


I've checked out a few other questions on here but they mostly seem to be asking about other specific problems. Help is greatly GREATLY appreciated!





Update Term Description in Admin Panel


I've replaced the default description with a Rich Editor ( wp_editor ) using the {$taxonomy}_edit_form_fields hook and saving them using the edited_{$taxonomy} hook. Originally, I thought I could use that same hook, check if my editor had content, then use wp_update_term to save it into the actual term description. I ended up running into a infinite loop as it turns out that wp_update_term actually also runs edited_{$taxonomy} and thus calls itself again and again...


What would be a good way to circumvent this problem? Is there a filter the the form update runes that wp_update_term does not?





Using two permalinks for one post


Using two permalinks for one post


I am developing a wordpress website for a client, the client want to show 2 separate templaes for post details the scenario will be.


user clicks on post and our default single.php will load up, there have a play button when user click on play button then instead of post name in permalink I want to add /play/post-name and need to load second template for that.


searched on internet and found some suggestions like Maintaining two permalink structures and https://wordpress.org/support/topic/multiple-posts-in-1-permalink but these are not working and also these are trying to add at the end of the link but i need it to before post-name


any help will be appreciated.


thanks





How to throw error to user when saving post


I made a custom post type and on saving its additional data I want to check if I a published post exists by its name. It works alright if there is, but I would like to throw some notice if article is not found.



$post_exists = $wpdb->get_row("SELECT post_name FROM wp_posts WHERE post_name = '" . $_POST['article_name'] . "' AND post_type = 'post'", 'ARRAY_A');
if($post_exists)
update_post_meta($id, 'article_name', strip_tags($_POST['article_name']));
else
???


I noticed there is http://codex.wordpress.org/Class_Reference/WP_Error but I dont think that is what I want since debugging is set to false?. Error could be anything - some usual notice would be fine, but even simple javascript alert could be good. Currently it tells me that the post is saved with green lights which doesnt seem right http://s1.postimg.org/kmjjjvuvj/image.jpg





How to change Disqus "count comments" underline color


I try to change Count comments underline color but it won't change


i used this code



.nav-primary>ul>li.active>a:after {
background: #69bd43 !important;
}


But no change


See below screen shot


enter image description here





problem by dispaly inserted form


i've build a form and insert it's data into custom db by $wpdb.


when i click on submit button, page reloaded and one row add to db but not any thing display in website.


you can see it at: my site link


my insert code is:



function insert_form() {

global $wpdb;
$table_name = $wpdb->prefix . "food_resarved";
$alibaba = $wpdb->insert( $table_name, array('id'=>'','user_id'=> wp_get_current_user()->ID,'name'=> wp_get_current_user()->user_firstname,
'lastname'=> wp_get_current_user()->user_lastname ,'post_title'=> $_POST['post_title'],'food_selected'=> $_POST['food'] ,
'guest_number'=>$_POST['guest_food'],'email'=> wp_get_current_user()->user_email ), array( '%d', '%s', '%s' , '%s' , '%s' , '%s' , '%s', '%s' ) );


if ( !$alibaba ) { $mylink = $wpdb->get_results( "select * from wp_food_resarved where user_id like '".$curent_user."' AND post_title like '".$abcde."' "); foreach ($mylink as $posta){ echo ''; echo ' شما '; echo $posta->food_selected; echo ' سفارش داده‌اید '; echo ''; } } else {echo "Die";} }