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

Kaleb on "Shortcodes vs Virtual Pages"

$
0
0

I'm trying to find out if there are any best practices for using shortcodes vs virtual pages in a plugin. Currently I'm developing a plugin that does both.

It provides a handful of frontend virtual pages that "just work" for general users including the ability to select page templates for these virtual pages (theoretically). The virtual pages process shortcodes to display content thereby making shortcodes available to users to use in their pre-existing pages. Also, you can override the virtual pages by simply create a page in through the backend, using the same slug structure to override nested virtual pages, and create your own.

Is this is a good or bad practice?
Is there another way I should be thinking about this?


BloggerDave on ""WP Facebook Open Graph Protocol" Modification"

$
0
0

I am sure many users of this plugin "WP Facebook Open Graph protocol" have found a small (but frustrating) problem with it. If you have set a default image in "Default Image URL to use", then even if you do not select "Force Fallback Image as Default," the default image will be shown as the first choice when you share your page on facebook. Most users would prefer that images from the post should be used instead.

I checked the code today and believe I have found the problem. Since I don't know where to post a bug for a plugin, I thought I would just post it here:

Look for the following code:
// Add the fallback image to the images array (which is empty if it's being forced)
if ( isset( $options['wpfbogp_fallback_img'] ) && $options['wpfbogp_fallback_img'] != '') {

Note the first condition in the if statement checks for the fallback image instead of checking whether the force flag is used. Just change it to the following code:

// Add the fallback image to the images array (which is empty if it's being forced)
// if ( isset( $options['wpfbogp_fallback_img'] ) && $options['wpfbogp_fallback_img'] != '') {
if ( ($options['wpfbogp_force_fallback'] == 1) && $options['wpfbogp_fallback_img'] != '') {

Now it will check for 'wpfbogp_force_fallback', so it will work as described in the plugin description.

You are welcome. :-)

ionurboz on "How to disable auto wordpress emmed script"

$
0
0

How to remove this script in the wp-footer:

e.g./wp-embed.min.js?ver=4.4

wp_deregister_script( 'wp-embed.min.js' );
wp_deregister_script( 'wp-embed' );
wp_deregister_script( 'embed' );

Do not work -.-

ahermon on "Help putting Javascript in page"

$
0
0

Hello,
I am doing some volunteer work for a non-profit. I am not an expert by any means. I have a non-wordpress page with javascript that I need to convert to work in a wordpress page. Any fairly detailed instructions would be appreciated.

<!DOCTYPE html>
<html class="html"><head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<meta name="generator" content="7.3.5.244"><title>Give to Hope</title>

<!-- Other scripts -->
<script type="text/javascript">
document.documentElement.className += ' js';
</script>
</head>
<body>
<div class="shadow clearfix" id="page">
<div id="cpb6a6797723" style="margin: 10px 0pt;" onclick="document.getElementById('pay_now_form_f0842ddb20').submit()">
<div>
<form action="https://globalgatewaye4.firstdata.com/pay" id="pay_now_form_f0842ddb20" method="post"><input name="x_login" value="WSP-HOPE-Egm9@xxxxx" type="hidden"><input name="x_show_form" value="PAYMENT_FORM" type="hidden"><input name="x_fp_sequence" value="140561766910534xxxxx" type="hidden"><input name="x_fp_hash" value="PNB-1.0-d44cdf92c09d5060ca295f276ab9c6187c3xxxxx" type="hidden"><input name="x_amount" value="" type="hidden"><input name="x_currency_code" value="USD" type="hidden"><input name="x_test_request" value="FALSE" type="hidden"><input name="x_relay_response" value="" type="hidden"><input name="donation_prompt" value="Please enter the amount you wish to donate" type="hidden"><input name="button_code" value="Donate Now Hope Church" type="hidden">
<div class="cpwrap"><button type="button">Donate
Now</button></div>
</form>
</div>
</div>
&nbsp;
<script type="text/javascript">if (document.location.protocol != 'https:') document.write('\x3Cscript src="http://musecdn.businesscatalyst.com/scripts/4.0/jquery-1.8.3.min.js" type="text/javascript">\x3C/script>');
</script>
<script type="text/javascript">
window.jQuery || document.write('\x3Cscript src="scripts/jquery-1.8.3.min.js" type="text/javascript">\x3C/script>');
</script></div>
</body></html>

bb1121 on "Image updating automaticaly"

$
0
0

I apologies in advance if this issue has already been raised. I tried to search everywhere for that.

I was wondering if anyone could help me with a few simple tricks.
Still a beginner to wordpress, I wanted to know if there was a way to automatically update (loop) pictures every Monday and Thursday (every week)

The picture are currently in the footer of the widgets.

That picture when clicked sends you to the picture's page.

The picture is a media upload on a page.

If anyone could help me figure out a way that is possible, I would greatly appreciate it !!!

Just to clarify, the pictures are a group of pictures that are already uploaded somewhere on another page. They are found in the footer of the widget.

Thank you !

susanevanskelly on "site hacked user name not recognised no access to wordpress site or cpanel"

$
0
0

site http://www.goodtochina.com has been hacked and re diverted to another site. I cannot access the wordpress admin panel as my username is not found.
Please can you help me to get access to the site - if my username is rejected (and not as a result of bad password).
many thanks

cgdesierto11 on "Disgruntled former CTO hacked our admin office"

$
0
0

A former CTO of our company hacked into our back office. I changed the user/pass credentials several times already but he still manages to gain access in our admin office. We've had our attorney send him a demand letter already but yet he still continues to breach our Wordpress back login. This is becoming destructive to our operation and having our legal counselor send demand letters every time he makes these changes is becoming costly. Please help me regain our back office and block him from future access.

Our site login: http://www.cannaeo.com/blog/wp-login.php

aoverbury on "WPUser->add_role not really adding role"

$
0
0

I've put together a script to update roles on a number of users on my wordpress site. It reads a simple CSV file to know what role or roles to give to a particular user, looks up that user by their user ID, and then checks to see if they have a particular role already, adding it if they don't.

error_reporting(E_ALL);
require("../../wp-load.php");

$source_file = 'role_source';

if(($source_handle = fopen($source_file, "r")) !== false) {
	while(($row = fgetcsv($source_handle)) !== false) {
		if(count($row) > 2) {
			if(($user = get_user_by('id', $row[1])) !== false) {
				for($i = 2; $i < count($row); $i++) {
					if(!$user->has_cap($row[$i])) {
						$user->add_role($row[$i]);
					}
				}
			}
		}
	}

	fclose($source_handle);
}

If I check the users in the database afterwards their wp_capabilities entries in wp_usermeta have been updated, but that's all. In my template when I call current_user_can() with one of the roles that should have been added to my test user (and that I can see listed in the database) it returns false. So it looks like there's something else that should be happening that isn't, or something else I should be doing that I don't know about.


peexie on "Text formatting in Ultimate Shortcode tabs"

$
0
0

Hi Guys, I use the latest version from Ultimate Shortcode plugin (it's a great stuff). But, I need to add formatted text into the tabs (U know, titles, sometimes images, etc.). Is there any way to do this? I mean really ANY, it is important now.
Thanks a lot!

naszymidrogami on "Display all post galleries in one Lightbox"

$
0
0

Hello,

I meet lots of people asking for Lightbox to show only current gallery images, not all galleries in a post/page. Actually I'm looking for something 100% opposite - I want all my galleries (wordpress galleries from JetPack) to be displayed in one lightbox, without a need to scroll to next one and click the first image in there.

I believe it's a simple trick for that. I use Efekt Lightbox plugin and prefer to stick to that, as it enables me to select images size to be shown in Lightbox (I also use Retina 2x plugin so it's important to me that Lightbox always shows Large type of image).

Website is: http://naszymidrogami.com

Many thanks for your support!

Marcin

WP Junky on "Disable all Gravatar.com support and Calls to Gravatar.com"

$
0
0

I'm wondering if anyone can help me with how to disable all third party calls to Gravatar.com within wordpress.

The Problem:
I run a few sites that use WordPress as a CMS and not really as a blogging platform. These sites are ecommerce and shopping related and thus don't really use or require comments or gravatar support. I'm not interested in using avatars or gravatars for post authors etc so I'm not concerned if I need to disable all avatar functionality.

I've disabled Gravatars/Avatars withing settings>discussion but that only stops gravatars and avatars from being displayed. Upon each page load a call/query to "Gravatar.com" is still made, even though I'm not using the feature. I'd like to STOP the calls to Gravatar.com since I'm painstakingly optimizing the sites for speed and this is a small but still unnecessary request made.

ATTEMPTED SOLUTIONS:

Ideally I'd like to do this through functions.php within a child theme or something similar. I try to keep plugin use to a bare minimum as well. Gravatar support is within Wordpress core and obviously I don't want to edit any core files. I'm looking for a simple coding solution but admittedly I'm not the greatest with hooks, filters and php.

1. As stated, disabling gravatars within WordPress "Discussion" settings doesn't work to stop the requests to Gravatar.com. It only prevents them from displaying on the site. The site still calls Gravatar.com upon loading.

2. I've attempted adding the following different solutions I've found in my search. I've added these within functions.php at different times and none have worked:

add_filter( 'get_avatar', 'so_disable_gravatars', 10, 2 );
function so_disable_gravatars( $avatar ) {
    $avatar = '';
    return $avatar;
}

and

add_filter('get_avatar', 'get_no_gravatar', 1, 2);
function get_no_gravatar( $id_or_email, $size = '96', $default = '', $alt = false ) {
   // put your new function in here
        $avatar = "<img alt='image_alt' src='#' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
	return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);
};

I've searched the forums and Google extensively and I'm not finding anything that works. Most posts are from 2-4 years ago or older.

I don't want to use a plugin for this but when I did do a plug in search it mainly returned old plugins that haven't been supported or updated in over 2 years.

I realize this isn't having a huge performance impact but it's a journey I've set out on and there's no looking back. At this point this has become a battle I have to win as a matter of principle. ;)

Can anyone help with a solution on how to easily disable calls to Gravatar.com when you're not using Gravatars at all?

Cryback78 on "Pagination url rewriting"

$
0
0

Hi,
Why when i run this function the pagination doesn't work.
Error 404.
if you have any suggestions, I'm interested.
Thank you beforehand

function filter_post_link($permalink, $post) {
    if ($post->post_type != 'post')
        return $permalink;
    return 'the-blog'.$permalink;
}
add_filter('pre_post_link', 'filter_post_link', 10, 2);

add_action( 'generate_rewrite_rules', 'add_blog_rewrites' );
function add_blog_rewrites( $wp_rewrite ) {
  $wp_rewrite->rules = array(
    'the-blog/([^/]+)/?$' => 'index.php?name=$matches[1]',
    'the-blog/[^/]+/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
    'the-blog/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
    'the-blog/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
    'the-blog/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
    'the-blog/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
    'the-blog/([^/]+)/trackback/?$' => 'index.php?name=$matches[1]&tb=1',
    'the-blog/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?name=$matches[1]&feed=$matches[2]',
    'the-blog/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?name=$matches[1]&feed=$matches[2]',
    'the-blog/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?name=$matches[1]&paged=$matches[2]',
    'the-blog/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?name=$matches[1]&cpage=$matches[2]',
    'the-blog/([^/]+)(/[0-9]+)?/?$' => 'index.php?name=$matches[1]&page=$matches[2]',
    'the-blog/[^/]+/([^/]+)/?$' => 'index.php?attachment=$matches[1]',
    'the-blog/[^/]+/([^/]+)/trackback/?$' => 'index.php?attachment=$matches[1]&tb=1',
    'the-blog/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
    'the-blog/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
    'the-blog/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?attachment=$matches[1]&cpage=$matches[2]',
  ) + $wp_rewrite->rules;
}

Dudo on "Question about filter / action priority"

$
0
0

in my main plugin I filter the_content to add rich snippet, something like this:

favorite

in my main plugin I filter the_content to add rich snippet, something like this:

add_filter('the_content', 'add_schema');

function add_schema($content) {
        $schema=NULL; //To avoid undefined variable notice outside the loop

        $review_choosen = get_snippet_type();

        //Use apply filter to allow users to customize the rich snippet
        $schema = apply_filters( 'filter_schema_microdata', $review_choosen )

        //If $schema is not false mean the user added his filter and return this one
        if ($schema) {

            return $content . $schema;

        }

       //DEFAULT CODE HERE

}

At the begin of the function, I use apply_filter to let my user or other developer to customize the rich snippet instead use the defaults that my plugin adds.

If the add_filter is put on functions.php, everything is ok.

But now I'm working on an extension that run on plugins_loaded. So when I try to use add_filter here this is what happens:

If I use

add_filter ( 'filter_schema_microdata', 'callback_function' )
    function callback_function ($review_choosen) {

the $review_choosen var is empty.

If instead, I try to put an higher priority, e.g. 9

add_filter ( 'filter_schema_microdata', 'callback_function', 9 )
   function callback_function ($review_choosen) {

The $review_choosen var is ok, but the functions doesn't return nothing.

So in which action should I run the add_filter?

R on "Woocommerce localization"

$
0
0

Hi guys,

I need your help. I keep having this problem and can't seem to find a way to fix it online...

I mainly use woocommerce in Portuguese and I have changed a bit the official translation to better suit my needs. I have placed the file woocommerce-pt_PT.mo at

wp-content/languages/plugins

and the personalize translation works fine. The problem is that it gets overwritten at each new update. Where shall I place the file so I can keep my translation ? I have tried at wp-content/languages/plugins/woocommerce but then the translation doesn't work.

Any help is very welcomed :)

Thanks

mslade on "How does parse_query()'s search_terms parameter work, if at all?"

$
0
0

The documentation for parse_query indicates that it can accept a search_terms argument, an array of search terms. Passing this into get_posts() does not impact the results based on my tests.

Looking at the code, it looks like search_terms is not actually used anywhere. get_posts may call parse_query if you also provide the s parameter (which seems pointless if you're providing search_terms), and that may <i>set</i> search_terms, but I don't see anywhere in query.php that it's actually used.

Can anyone enlighten me?


macbookandrew on "Testing for shortcode output"

$
0
0

Is there a way to test for shortcode output and perform actions based on that?

I’ve tried this code, but either it doesn’t run at all or it generates PHP out-of-memory errors.

if ( do_shortcode( '[so_show_offers]' ) != NULL ) {
    // take action
}

Use case: I’m trying to redirect to a specific page if the shortcode has content; if not, then redirect to a different page.

Thanks

D C on "SQL script for publishing"

$
0
0

So I am running into some issues here with auto publishing. I am mimic the process that accure once the Publish button is pressed with an SQL script.

A bit of backstory:
I have a site that it is feed posts from feedly. By default these posts are put into draft mode. Using the following script, I have figured out a way to change the post from draft to publish.
UPDATE DB_Name.wp_posts SET post_status = replace(post_status, 'draft', 'publish'), post_name=id where post_status = 'draft';

This works great and does switch from draft to publish and does assign a slug. However, when a post comes from feedly, it does not create a featured image. To do this, I have installed a plugin (Quick Featured Images Pro). The plugin basically scans the post and uses the first image it sees as the featured image.

Here is the catch. The plugin only works if you the feedly post is set to draft first and then you manually login and click publish. Thus, my script only makes the chagnes in the database, but does not fully do what I need.

So my question would be, does anyone know how to script (php or sql) the process of pushing the publish botton? Or better yet, how to run the plugin script after my script above is run?

Thanks in advance.

ppng on "user-activation/?act_error=1"

$
0
0

when I try to login wp admin control
can't open and url : yoursite.com.br/user-activation/?act_error=1

how to fix it ?

thomaslester on "Get image from post in other custom post type"

$
0
0

Hello!
I´m making an event listing with custom post type = "events"
I also have a custom post type = "artists"

In "events" I have a ACF = "Artist" where the custom field type is "Relationship". With this I can link an artist to an event.

The output from the "Relationship" artist field is the post_id number from the chosen "artist" post.

In the loop for "events" I would like to add the Name and the thumbnail from the "artist"
This should all be shown on a page, not on a single post.

How can I do that?
Have used 5hours trying everything, but ends up with nothing. Any help will be appreciated a lot.

tinypinc on "Coding problem regarding footer message"

$
0
0

Hello :)

I'm trying to change my site's footer message.
Instead of the wordpress link and theme,

I would like to put "TinyPinc Miniatures 2010-2016"

How do I do that with the current coding I have?
I'm new to this,
hope someone can help me rewrite it haha.
I get so confused with the coding...

<div class="site-info">
"><?php printf( esc_html__( 'Proudly powered by %s', 'dyad' ), 'WordPress' ); ?>
<span class="sep"> | </span>
<?php printf( esc_html__( 'Theme: %1$s by %2$s.', 'dyad' ), 'Dyad', 'WordPress.com' ); ?>
</div><!-- .site-info -->
</div><!-- .footer-bottom-info -->

Thank you :)

Viewing all 8245 articles
Browse latest View live