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

andy_woz on "Rewrite shortcode if mobile device."

$
0
0

Hi I have an older site that uses a flash based audio player proprietary shortcode in the page content. What I'd like to do is to switch to an HTML5 audio player for mobile devices. I guess I'd be looking for a filter to replace shortcode content based on device?

I know wordpress has an wp_is_mobile() function. Could that be used to rewrite shortcodes in the content?

I'd need to change shortcodes in the format [audio:http://myaudiosource.com/filename.mp3|titles=My audio Title]
to
[audio src="http://myaudiosource.com/filename.mp3|titles=My audio Title"]
for mobile devices, assuming the |titles part wouldn't break the player.

Maybe I could do a preg_replace() just not sure how to target the shortcodes in a function.

Thanks!


skunkbad on "Hook to check comments for enqueue_script"

$
0
0

I tell you what, searching on Google is totally worthless when you need to look for information about plugin development related to comments. Yes, you can find page after page of the 10 best WP plugins, and you can find page after page of comment plugins, but it's very hard to find what I need, so I'm asking here.

I currently use add_action('the_posts', 'x') to look at posts so I can check for pre tags and use enqueue_script to load some js.

All I want to do is the same for comments. I have tried "the_comments", but that doesn't work. I only need this done on blog singles.

Any help, please!

FatLabllc on "Getting delete query to work in wp-cron"

$
0
0

I have been struggling with this for a little while now and hoping someone can provide some advice.

I am writing a plugin that includes a wp-cron job to delete records from a table after they are 24 hours old. The cron job is created just fine on activation and using several cron related plugins I can see and execute the cron job without issue. However the table rows meeting the 24 hour criteria are not deleted. My code is below.

Thanks so much for any insight!

register_activation_hook( __FILE__, 'sap_create_schedule' );

	function sap_create_schedule() {
		wp_schedule_event( time(), 'hourly', 'sap_hourly_cleanup' );
	}

	add_action( 'sap_hourly_cleanup', 'sap_cleanup' );

	function sap_cleanup() {
	$table_name = $wpdb->prefix . "sap";
	$wpdb->query("DELETE FROM $table_name WHERE creation_time >= now() + INTERVAL 1 DAY");
	}

loiste2 on "Override the Wordpress core function wp_referer_field"

$
0
0

I'd like to override the core Wordpress function wp_referer_field with folowing code:

function wp_referer_field( $echo = true ) {
$referer_field = '<input type="hidden" name="_my_wp_http_referer" value="'. urldecode(esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) )) . '" />';

if ( $echo )
    echo $referer_field;
return $referer_field;}

I've found that wp_referer_field is not pluggable and that I need to use some other technics for that. Adding some filters or actions. I was trying to use these code:

add_filter( 'wp_referer_field' , 'wp_referer_field_cyrillic' );
function wp_referer_field_cyrillic( $echo = true ) {
$referer_field = '<input type="hidden" name="_my_wp_http_referer" value="'. urldecode(esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) )) . '" />';

if ( $echo )
    echo $referer_field;
return $referer_field;}

But it doesn't work. It seems that I did something wrong.

adrianlittee on "Using jQuery .load() function with wordpress and gravity forms"

$
0
0

I am developing a series of pages which will integrate with Gravity Forms.

I'm using jQuery to send data to a div from a page I have created.

Requesting Page

<a href="#" onclick="showEntry(\''.$url.'\')">View</a>
<div id="viewEntry"></div>

Javascript/jQuery page

function showEntry(url){
    jQuery(document).ready(function($){
        $('#viewEntry').load(url);
    });
}

PHP data page - entry.php

$form_id = $_GET['f'];
$form = GFFormsModel::get_form_meta( $form_id );

var_dump($form);

When ever I click run I get an error in my log file saying: PHP Fatal error: Class 'GFFormsModel' not found in

I want to know how I can get the entry.php file recognizing all the classes in the rest of my Wordpress file system.

Any help would be great!

Kassandra_P on "Change Sort Order of Image Attachment Pages"

$
0
0

Hi, I'll try to break this down as clearly as possible:

I have several galleries.
The images in each gallery are sorted (alphabetically by last name) according to the image slug.
When you click an image in the gallery, it takes you to the attachment page for that image.
The attachment pages also have navigation so you can cycle through them using previous_image_link / next_image_link

My problem is that the attachment page navigation cycles through the pages in order of date uploaded, rather than by slug like the galleries.

So, how can I sort my image attachment pages by slug?

I'm terrible at php, but I've researched it and it looks like I'll need to create a new WP_Query for attachments. Something like this?

$attachment_navigation = new WP_Query(
array(
    'post_type' => 'attachment',
    'post_parent' => null,
    'post_mime_type' => 'image',
    'post_status' => 'inherit',
    'orderby' => 'slug',
    'order' => 'ASC',
    )
);

From what I've read though, orderby slug doesn't work -- what should I use instead?

And then -- what else? Do I have to write another function to put it into effect? PHP newb here...

Thanks for your help!

Sprinto on "Show posts from auther"

$
0
0

Hey guys,

Im having a problem with getting recent posts from a specific auther.

I found a function that let be do it.

function my_get_display_author_posts() {
    global $authordata, $post;

    $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ) ) );

    $output = '<ul>';

    $i = 0;
    foreach ( $authors_posts as $authors_post ) {
        $output .= '<li><a href="' . get_permalink( $authors_post->ID ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></li>';
        if(++$i > 4) break;
    }
    $output .= '</ul>';

    return $output;
};

But it only takes post 2,3,4,5 and not the most recent post.. Can anyone help me out? You can take a look at a post here: http://trendthis.dk/ny-bikini-trend-wtf/

madsrh123 on "How to increase numbers if exist"

$
0
0

Is there a more efficient way to increase these numbers? I've looked into $i++ but couldn't make it work.

<?php $args = array( 'post_type' => 'album' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();

	$track1 = get_field('track1');
		if($track1 !== '') {
		echo '<br><strong>1 <strong>'; the_field('track1'); } 

	$track2 = get_field('track2');
		if($track2 !== '') {
		echo '<br><strong>2 </strong>'; the_field('track2'); } 

	$track3 = get_field('track3');
		if($track3 !== '') {
		echo '<br><strong>3 </strong>'; the_field('track3'); }
endwhile; ?>

loenne on "Hide comment email from non-admins"

$
0
0

I have a question about comment notification

When someone posts a comment there are sent 2 emails - one to me as Admin and one to the author.

However, the email sent to authors contains the email address of the person making the comment.
Since most of our authors are 3rd party people I can't have email addresses shown to them - seems like a huge breach of privacy.

How can I hide email addresses from people making a comment from all emails sent?

Authors can also see the email in wp-admin, when editing their own posts. Can I remove it from there as well?

kshilpa1385 on "WordPress Login credentials Pass to another site"

$
0
0

[Moved from Your WordPress which is NOT a support forum.]

hi,

I have 2 websites one is in wordpress and another is in asp.net.

I want pass login credentials of wordpress to asp.net

So please tell me how should do it?

I am new in wordpress, so please help me.

infocolombol@libero.it on "Pages and comments exist but are not visible"

$
0
0

Hello everyone, after it has been updated on the server, the pages and comments of my site are no longer visible.
http://www.menbillionaires.com
Thanks for the help

[Moderator Note: Please ensure that you are embedding links correctly in your posts.]

hixen on "Found some pretty complex malicious code"

$
0
0

Hello,

Found some malicious code on my site and I don't really understand it, but it seems pretty complex. So I'm posting it here if someone needs to take a look, and prevent this from happening to others.

I'm not sure if it's a security hole in WordPress, or if my hosting partner got hacked, but here it is:

index.php (last modified: 2014-02-21)
http://chopapp.com/#1mpyxybd

It's a wall of text, since it's decoded, but using http://ddecode.com/phpdecoder/ i managed to make it more readable.

same chuck of code more readable:
http://chopapp.com/#68wz01zp

but if you are looking there are still some parts that are decoded using base64_decode. (used http://www.base64decode.org/ to decode it)

line 889 base64_decode:
http://chopapp.com/#vw8odqri

line 896 base64_decode:
http://chopapp.com/#arm4fjp6

line 899 base64_decode:
http://chopapp.com/#ndpufpn7

line 1427 base64 decode:
http://chopapp.com/#4fazalz7

line 1804 base64 decode:
http://chopapp.com/#4m45tzbt

also found this in the code:
D.K Shell v1.0
D.K Shell (c)oded by b47chguru & Lnx Root for ICF
D.K shell is made on the same architecture of WSO shell. D.K shell is a professional web shell..
It has all the features to bust the security..including disabling mod_security , disabling php safe mode, Symlink,webcrawler, auto-admin password changer for vbulletin,joomla,Wordpress...etc, perl cgi scipt compatibility and a better backconnection script.For any doubts or queries on D.K shell mail me at interestingpal@gmail.com Note:The security on the webserver is completely disabled when clicked on the 'safemode' link and the default port for php backconnection is 70
Special Thanks to Archith Kp who helped generously throughout the project..!!

Liked I said, pretty complex.

And those who are wondering, my site is ok, nothing was lost, and it was a empty demo site.

dacosta_rafael on "some of post deletes upon saving"

$
0
0

I have the following filter but when I save the post some of the post content gets deleted. Is there an alternate solution?

function filter_post_data( $data, $postarr ){

$content = $data['post_content'];
$title = $data['post_title'];
    $search = array(chr(145),
                    chr(146),
					chr(147),
					chr(148),
					chr(150),
					chr(151)
					);

    $replace = array("'",
                     "'",
					 "'",
					 "'",
					 "-",
					 "-"
					 );
 	$contentSanitized = str_replace($search, $replace, $content);
	$titleSanitized = str_replace($search, $replace, $title);
	$data['post_content'] = $contentSanitized;
	$data['post_title'] = $titleSanitized;
//print_r($data);
	return $data;
}
add_filter( 'wp_insert_post_data' , 'filter_post_data' , '99', 2 );

[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

pixel016 on "How to update image"

$
0
0

Hi everybody,

I have a custom field "upload image" on the user profile page.
When the user upload an image, it appear on the wordpress media library and on a featured image on a custom post.

So the first upload is ok, the image update is ok but when we do the update when there is no new image it removes the old image. (sorry for my english).

I use this code

$thumbnail_id = get_post_thumbnail_id( $post_id );

            if ($thumbnail_id == "") {
                  $attach_id = wp_insert_attachment( $attachment, WP_CONTENT_DIR . '/uploads' . $filename, $post_id);
                  require_once( ABSPATH . 'wp-admin/includes/image.php' );
                  $attach_data = wp_generate_attachment_metadata( $attach_id, WP_CONTENT_DIR . '/uploads' . $filename );
                  wp_update_attachment_metadata( $attach_id, $attach_data );
                  set_post_thumbnail( $post_id, $attach_id );
            }
            else {
                  $attach_id = wp_insert_attachment( $attachment, WP_CONTENT_DIR . '/uploads' . $filename, $post_id);
                  require_once( ABSPATH . 'wp-admin/includes/image.php' );
                  $attach_data = wp_generate_attachment_metadata( $attach_id, WP_CONTENT_DIR . '/uploads' . $filename );
                    wp_delete_attachment($thumbnail_id );
                    wp_update_attachment_metadata( $attach_id, $attach_data );
                    set_post_thumbnail( $post_id, $attach_id );

            }

kater89 on "Save jQuery UI Sortable"

$
0
0

I have a simple jQuery Sortable code and I need it to save when the order is changed.

I have seen this post but I can't get it to work.

I think my main issue is I don't know where to put this:

$args= array(
    'meta_key' => 'c3m_shown_on',
    'meta_value'=> 'home'
    'orderby' => 'menu_order',
    'order' => 'ASC'
);
$box_query = new WP_Query($args);

Here is the basic part of my code ...

HTML:
<ul id="sortable">
<li class="ui-state-default">Item 1</li>
<li class="ui-state-default">Item 2</li>
<li class="ui-state-default">Item 3</li>
</ul>

jQuery:
 <script>
$(function() {
$( "#sortable" ).sortable();
 });
</script>

*Note I am using Multisite


madsrh123 on "$_Session inside while"

$
0
0

I need to bring the $i to my target page.
This gives me a list of track titles with a permalink, but on my target page I only get the last $i.

<?php $args = array( 'post_type' => 'album' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
$i = 1;

	the_title();

	// Gets track ID foreach track
	while ($i > 0) {
 	   $track = get_field ('track'.$i);

 	$permalink = get_permalink( $id );
 	session_start(); // STARTS VARIABLE TO SEND I TO NEXT PAGE
           $_SESSION['variable_name'] = $i;

 	   if ($track != '') {
		echo '<br><a href="' . $permalink . '"><strong>' . $i . ' <strong>' . get_field ('track'.$i) . '</a>';
		$i++;
	    }
	    else {
	        $i = 0;
	    }
	}

endwhile; ?>

And the target page contains:

session_start();
echo $_SESSION['variable_name'];

markoof on "WooCommerce Variable product shortcode"

$
0
0

Hello,

does anyone have an idea how to call variable product form with shortcode?

More details:

I have two variable products on the site and when I visit product page, there is an option to choose product variation - http://bit.ly/YJSvco scroll down to the bototm of the page content.

What I need is to create a page that will show all products (like a post list), but that will include this form as well at the end of each post.

I can create custom page template that will pull products with custom WP Query, but not sure how to add forms that will allow me to order products.

It would be even better if I could add it as shortcode, and to have one page that will include description of both products with forms included.

e.g

{product 1 description}

[form_shortcode product="product_id"]

---------------------------------------------------

{product 2 description}

[form_shortcode product="product_id"]

Any idea? Thanks

sj3vans on "How to embed Wistia video iFrame link with user tracking"

$
0
0

I can't seem to figure this out. Perhaps someone can direct me how I need to get it going.

On our homepage at vistaone.tv, you can see that when I place the following link in a post, it embeds the video in an iframe such that it can play in place, without leaving the page, which I like a lot:

http://vistaone.wistia.com/medias/lyxk4fqan6?embedType=iframe&videoWidth=640

But I wanted to add a tracking parameter so I can find out who watched the video based on their WordPress login (I'm also using S2member). When I tried to embed the currently logged in user's email, it no longer displays the iFrame. Here's what I've tried:

<?php
global $current_user;
get_currentuserinfo();
echo 'http://vistaone.wistia.com/medias/lyxk4fqan6?embedType=iframe&videoWidth=640&wemail=' . $current_user->user_login; ?>

The substitution works, but I see the actual link instead of the video in an iFrame.

Any suggestions?

veggieboy516 on "Pods setup template boolean code help"

$
0
0

Hi!

I'm trying to incorporate an if statement into the code in the Pods=>Setup=>Template part. Goal if value is false, display.

Under Pods=>Setup=>Pods, I've added column with the column type boolean. Called it noquestion. In my case, check the box if there are no questions. Box checked => value true; there are no questions, don't display option of clicking on question. If box not checked => value false, display option of clicking on question

Here's part of the code in the Pods=>Setup=>Template:

<a href="{@manuscript}" target="blank" alt=" " title="Download the manuscript."> <img class="sermon_img" src="<?php bloginfo('template_url'); ?>/images/sermons_download_arrow.png"></a>
<a href="{@questions}" target="blank" alt=" " title="Download the discussion questions."><img class="sermon_img" src="<?php bloginfo('template_url'); ?>/images/sermon_q_download_arrow.png"></a>
<a href="{@link_to}" alt="Save sermon audio." title="Save sermon audio."><img class="sermon_img" src="<?php bloginfo('template_url'); ?>/images/sermons_save_disk.png"></a>

I'm trying to get the middle section into the if statement:

<a href="{@questions}" target="blank" alt=" " title="Download the discussion questions."><img class="sermon_img" src="<?php bloginfo('template_url'); ?>/images/sermon_q_download_arrow.png"></a>

I thought I'd try:

if(@noquestion==0){<a href="{@questions}" target="blank" alt=" " title="Download the discussion questions."><img class="sermon_img" src="<?php bloginfo('template_url'); ?>/images/sermon_q_download_arrow.png"></a>;}

or some variation of that it would work, but none of variations I tired work. The if statement just pops up on the website.

First time looking for help on forums, hope I got everything; thanks for your time/offer to help.

Gardian on "Woocommerce - Simple Product informations"

$
0
0

Hello,

I need to get product information as product title, price , image link, product link, currency in a new plugin.

I am new with Woocomerce so not familiar with its classes and functions...

Could you help me to get that?
Thank you very much.

Viewing all 8245 articles
Browse latest View live




Latest Images