Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

janbrokes on "Conflict of search page and category page"

$
0
0

Hi,

this part of code I added to index.php page

<h1 class="pagestitle"><?php echo(get_category_parents($cat, TRUE, ' ')); ?> české návody</h1>
<div id="vypis">
<?php
if (is_category()) {
$this_category = get_category($cat);
}
?>
<?php
if($this_category->category_parent)
$this_category = wp_list_categories('orderby=id&show_count=0
&title_li=&use_desc_for_title=1&child_of='.$this_category->category_parent.
"&echo=0"); else
$this_category = wp_list_categories('orderby=id&depth=1&show_count=0
&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID.
"&echo=0");
if ($this_category) { ?>

    <?php echo $this_category; ?>

<?php } ?>
</div>

in order ho have fine H1 and list at category page f.e. here
http://www.ceske-navody.net/bosch/

But it causes problem in search here:
http://www.ceske-navody.net/?s=bosch

Is there any way how to selve it? For example add some condition tha will restrict that part of code at search page?

Thanks in advance
Jan


Maria Daniel Deepak on "Unable to find PHPUnit code coverage stats"

$
0
0

Where should I check for the code coverage stats when using PHPUnit for WordPress?

My WordPress setup:

I have setup WordPress using VVV and my testing suite includes PHPUnit and WP-CLI.

How I executed test cases to find code coverage?

When I execute phpunit command to test a WordPress plugin, I'm able to see, if the test cases passed or failed. In my case there were *no failures*.

To find the code coverage, I executed phpunit --coverage-text=./coverage.txt, the test cases passed but I'm unable to find the coverage.txt file to check the actual code coverage stats.

A search for coverage.txt file in plugin's folder using the Windows explorer returned no results. Am I missing something?

johnnyderdepp on "publish post shorthand"

$
0
0

Hello,

i want a button in the post-list and when i click it i change the post_status to 'publish' with ajax - this works perfect, but how can i "reload" this single post-row so that the changes will be visible and that i can hide the 'fast-publish-button'?

https://s31.postimg.org/lis3absbf/image.jpg

perthmetro on "Count the number of times a term has been viewed"

shivampaw on "WordPress admin_post not working"

$
0
0

Hi

I have the following code for my plugin. However it works as it should when I am logged in but when I am not logged in submitting the form takes me to a WP admin "Not Available" screen.

How come and what can I do to fix this?

<?php
    /*
    Plugin Name: Subscriber Check
    Version: 1.0
    Author: Shivam Paw
    Author URI: http://www.shivampaw.com
    Text Domain: subscriber-check
    Domain Path: /languages
    Description: Plugin that means a viewer must enter the email address for mailpoet to see content.
    */

    if (!session_id()) {
        session_start();
    }
    function subscriber_check_shortcode( $atts, $content = null ) {
    	if($_SESSION["subscriber_check"] == true){
    		return $content;
    	}else{
    		$message = "<p>Please enter the email you used when subscribing to our site to view this page. Once verified you will be able to access this page until you close your browser.</p>";

    		$error = "";
    		if( basename($_SERVER['REQUEST_URI']) == "?error"){
    			$error .= "<p style='color:red;'>The email you entered was not found. Please make sure you have confirmed your subscription. You must enter the email address you used when subscribing. If you can't remember the email then please re-subscribe.</p>";
    		}

    		$form = '
    		<form method="post" action="'.get_admin_url().'admin-post.php" id="subscriber_check_form">
    			<p>
    				<input type="hidden" name="action" value="submit-form-subscriber">
    				<input type="email" name="subscriber_check_email" id="subscriber_check_email" placeholder="Enter Your Email">
    				<input type="submit" name="subscriber_check_submit" id="subscriber_check_submit" value="Verify">
    			</p>
    		</form>
    		';
    		return $message.$error.$form;
    	}
    }
    add_shortcode( 'subscriber_check', 'subscriber_check_shortcode' );

    add_action('admin_post_submit-form-subscriber', '_handle_form_action'); // If the user is logged in
    add_action('admin_post_nopriv_submit-form-subscriber', '_handle_form_action'); // If the user in not logged in

    function _handle_form_action(){
    	if($_POST["subscriber_check_email"]){
    		global $wpdb;
    		$sql = $wpdb->prepare( "SELECT * FROM 2proiTFuxs_wysija_user WHERE email=%s AND confirmed_at IS NOT NULL",$_POST["subscriber_check_email"]);
    		$results = $wpdb->get_results( $sql);
    		$rows = $wpdb->num_rows;
    		if($rows != 0){
    			$_SESSION["subscriber_check"] = true;
    			header('Location: /free-downloads');
    		}else{
    			header('Location: /free-downloads/?error');
    		}
    	}
    }

letorthopper on "Reusing Content - Adding Single Posts"

$
0
0

I'm looking for an easy way to add a single post to a page. I get how I can do that with WP Query. Is there an easier way or an easier way to do what I describe?

My Example -
Lets say I want to add a departmental policy to pages where that policy applies. Additionally, that policy changes frequently. In other CMS's systems I've been able to reuse content, so I only have to update one content block and all of my pages are automatically updated. It made sense, at least initially, to set this policy up in a post, add the post to the pages where it applies, and update the post when needed - hence changing all the pages. Is the only way to do this through WP Query (or the older get_posts)? Am I thinking about this all wrong re: posts?

blaineh on "Shortcodes with Filtered Styles"

$
0
0

Hello,

I'm attempting to use the ASA shortcode to generate an inline style with attribute info from Amazon (width, height, etc. of an Amazon product).

I am somewhat familiar with the shortcode API (and its standards), but am having trouble echoing the shortcode as an inline style.

Currently, I am doing something along the lines of echo do_shortcode("<div [asa style-template]ASIN[/asa]></div>");

Unfortunately, do_shortcode fails to recognize the shortcode.

Any help or advice on whether or not this is doable would be greatly appreciated.

Thanks for your time.

Regards,

Blaine

DenisCGN on "Shortcode GALLERY"

$
0
0

Hello,
I try to customize the WP GALLERY shortcode.
I created my own shortcode to customize the gallery.

function kik_author_gallery_id(){
$the_images = get_post_meta( '181', 'kik_gallery' );
$the_images = implode( ',',$the_images );
return '[gallery columns="4" ids="'.$the_images.'" link="file"]';
}
add_shortcode( 'kik_author_gallery', 'kik_author_gallery_id' );

Now, when I put the shortcode [kik_author_gallery] into the post body it only shows this

[gallery columns="4" ids="184,185,186,187,197,198,367,368,369,370" link="file"]

Not the gallery itself.

Why?

Can someone help?

Cheers,
Denis


jancbeck on "How do I use translate.wordpress.org to translate my plugin?"

$
0
0

The relevant plugin is this:
https://translate.wordpress.org/locale/de/default/wp-plugins/acf-add-posts-via-relationship-interface

The note says "This plugin is not properly prepared for localization. If you would like to translate this plugin, please contact the author.". However, I have used the appropriate gettext function
__( 'Do you want to create a new object called "{title}"?', 'acf-add-rel' )

I do not use load_plugin_textdomain because in a recent post it was mentioned that this is no longer necessary:

By far the biggest change is that you do not have to call load_plugin_textdomain() or load_theme_textdomain() anymore with WordPress 4.6.

https://make.wordpress.org/core/2016/07/06/i18n-improvements-in-4-6/

So how do I use translate.wordpress.org? What are the necessary steps for my plugin? Do I have to include a .pot file? Where do I have to place it?

cpabell on "Questions about Metadata"

$
0
0

I installed a theme on my WordPress site that displays thumbnails of all the pages on my site that use the "portfolio-item" template. I love the theme, but wish it would go a little further and allow my clients to sort the portfolio items by category. By default, Wordpress doesn't have a category field for the pages, only blog posts. I was wondering if I could use WordPress' metadata to sort:
- first I'd create a custom field called "category" on every page
- assign each page a value for category
- and somehow tell the page to load only portfolio-items with the category value, depending on which one the client clicks on

I know this can be done using php, however I'm hoping to use metadata as I feel it'd be a little easier to control, since it's native to WordPress. Could anyone help me out with this?

Thanks in advance!

monkeybrain on "Custom editor button (works with visual but not text editor)"

$
0
0

I managed to create a custom editor button for the visual editor (following this tutorial http://code.tutsplus.com/tutorials/guide-to-creating-your-own-wordpress-editor-buttons--wp-30182 )

Is it possible to also add that button to the non-visual aka text editor? And if so, how is it done? (My client will use the visual editor, while I prefer the text editor. So i'd like to have the custom button in both editor views.)

I pretty much used the code from the tutsplus link, just changed <span class="dropcap"> to <div class="text-columns"> (so I'm not going to paste any code here)

Thanks!

chickspirit on "WooCommerce Product Image to External Link in New Window"

$
0
0

I have an external link product and would like the featured image on the single product page to link to the external page in a new window.

Out of the box the image, when clicked, opens in a lightbox.

The section of code I have to adjust is in the product-image.php

<div class="images">

	<?php
		if ( has_post_thumbnail() ) {

			$image_title 	= esc_attr( get_the_title( get_post_thumbnail_id() ) );
			$image_caption 	= get_post( get_post_thumbnail_id() )->post_excerpt;
			$image_link  	= wp_get_attachment_url( get_post_thumbnail_id() );
			$image       	= get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ), array(
				'title'	=> $image_title,
				'alt'	=> $image_title
				) );

Specifically I need to change this line:
$image_link = wp_get_attachment_url( get_post_thumbnail_id() );

I changed it to this:
$image_link = esc_url( $product->get_product_url() );
which accomplished the image opening the external link when clicked. However it's opening in the same window and I'd like it to open in a new window.

I tried this:
$image_link = esc_url( $product->get_product_url(), array('target' => '_blank', 'rel' => 'new_window') );
But now it just kind of refreshes the page and takes me nowhere.

Suggestions? Thank you!
Page I'm trying this on.

squarology on "Add a space after "Tags:""

$
0
0

Currently my tags appear without any space between "Tags:" and my tags so it looks like this:

Tags:test, wowzers

I would like to place a space between "Tags:" and "test" so that it looks more natural. Any idea how I'd do that?

simplywallst on "remove sizes attribute in IMG"

$
0
0

Guys I am pulling my hair out on this. Just want to remove the sizes attribute but keep the srcset attribute on all my IMG tags.

Something like this would work fine:
return preg_replace( '/sizes="(.*)"/', '', $html );

BUT the sizes and srcset is generated upon page rendering.

Please help!

kybernaut on "Fix missing nonces to POST calls in add_action"

$
0
0

Hi, I have created a plugin (a Czech extension for WooCommerce adding and validating VAT number and Company number) and tried to submit to the WP repository, however, I got back following:

## Not using Nonces and/or checking permissions

Please add a nonce to your POST calls to prevent unauthorized access.

Keep in mind, check_admin_referer alone is NOT bulletproof security. Do not rely on nonces for authorization purposes. Use current_user_can() in order to prevent users without the right permissions from accessing things.

https://codex.wordpress.org/WordPress_Nonces

In my code, there only place is this woocommerce add action:

add_action('woocommerce_checkout_process', 'kbtn_woolab_icdic_checkout_field_process', 10, 2);
		function kbtn_woolab_icdic_checkout_field_process() {
			if ( $_POST['billing_ic'] ) {
				if (!verifyIc($_POST['billing_ic'])) {
					wc_add_notice( __( 'Zadejte platnou hodnotu I?.', 'woolab-ic-dic'  ), 'error' );
				}
			}
			if ( $_POST['billing_dic'] ) {
				if (!(verifyRC(substr($_POST['billing_dic'],2)) || verifyIc(substr($_POST['billing_dic'],2))) || substr($_POST['billing_dic'],0,2) != "CZ") {
					wc_add_notice( __( 'Zadejte platnou hodnotu DI?.', 'woolab-ic-dic' ), 'error' );
				}
			}

		}

I have read the codex multiple times, but I have no idea how to add nonces in this situation. Could any body help me out? Thanks a lot, I would love to know more about it. Even on WooCommerce site there is nothing about it - https://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/


fernandob on "Appear image on click"

$
0
0

Hey,

I have this code that make the image appear when I hover the text it is targeting.
However, since it doesn't work with touch screen devices, I wanted to simply click on the link and make the image appear (and stay visible).

This is the code a I have:

.share-project-box { position:relative; display:inline-block; }
.share-project-box ul { display:none; position:absolute; left:100%; top:-7px; margin:0 0 0px 0px !important; min-width:200px;}
.share-project-box ul li { display: inline-block; list-style: outside none none; margin: 0px 0px 0px 10px ; width: 36px; }
.share-project-box:hover ul { display:block; }
.share-project-box:hover { text-decoration:underline; }
.share-project-box > h6 { margin:0px; }

I tried to search about it and the suggestions were to put :target but it is not working.
Can anyone help me?
It must be simple but I am a newbie on this :\

Thanks!

edosauyi on "Frontend User Search By Firstname For all Registered Users"

$
0
0

Please I really need this so so bad, I've tried using AMR Users and a lot of other WP Plugins but they can't give me what I really need.

I need a Frontend user search code for all registered users to be able to search other users by their "FIRSTNAME" and the result will ONLY display the "USERNAMES" of all users that has the search term in his/her "FIRSTNAME"

The usernames in the search result should be in plain text, not linking to anywhere.

It should not be limited to any user role, all users can search and all users can appear on search results.

leefuller on "How to conditionally hide or show content based on a Session Variable value?"

$
0
0

Have a need to hide or modify a certain piece of content (maybe hide or show a div) based on the value of a session variable?

Anyone have any simple suggestions for this?

Thanks, in advance, for the help...

1372377737k on "Jet pack -post by email"

$
0
0

Hi there,
I have a python program that generates a text file and sends this to an email address.

This works as I get the email delivered to the email address I stipulate in my python program.

If however I use the generated email address from jetpack, it is meant to create a new post with the email body as content. This does not work... no new posts are created.

If I forward the email messages I received (paragraph 2 above) to the jet pack generated email address, then post is successfully generated.

So it seems that my attempt to generate an email and have a post created from the email via python fails.

Is there somewhere I can find a log file to check the reason why this is not working?

ferocious on "Apropos capabilities"

$
0
0

Hello, what I'm looking to do is hide CPT from user to user. Currently any user can post and edit any CPT from his edit page, but I'd like that user can only edit/delete/post its contents. I have added a new role with add_role() then I gave it these capabilities via register_post_type() and add_cap() functions:

publish_products,
edit_products,
delete_products,
delete_product,
edit_product,
read_product

If user visits the edit page edit.php?post_type=my_product it lists the CPTs of all users and this is not good.

Viewing all 8245 articles
Browse latest View live




Latest Images