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

wibblebuilder on "Is there a "if no have_posts" hook?"

$
0
0

I have modified my search to only search my post title using posts_where hook but if the search returns no results I want to do another search looking at the post content, so is there way to check if there are no results?

Thanks


GemmaLeigh_11 on "How can I change the colour behind my responsive menu?"

$
0
0

I'm having a problem with my responsive menu

When viewed on an iPhone, Android or tablet, I like the layout of the menu but can't see where to change the colour of it in my style css sheet. Ideally it would be transparent so you can see the logo but if not, a different colour and beneath it

Can anyone help at all? I do know a little css but very basic, hence having bit of an issue. Where can I find the css to change it and what am I looking for - I've tried searching for it by the hex code

lightboxhouse.co.uk

Tatiane Pires on "How to make URLs work for categories and tags of custom post types"

$
0
0

Searching around the support topics, I've found one with a request similar to what I need [link 1 below], but that topic is closed.

My blog posts are in Portuguese, so I created a CPT named 'postsEN', with slug 'en', for a section on my blog where I intend to write content in English.

To create a category on default posts doesn't make it, because I don't want posts in English to be listed with posts in Portuguese. I don't want another blog either, that's why I'm not going to use the network feature for this purpose.

I published a dummy 'Hello World!' post under the new CPT:
tatianepires.com.br/en/hello-world/

The links for single posts are OK. The problem is I was expecting that the following links would work too:
tatianepires.com.br/en/category/my-new-category
tatianepires.com.br/en/tag/new-tag

The category and the tag above are displayed for "Hello World!" on /wp-admin/edit.php?post_type=postsen, but the links doesn't work.

Code for register-custom-post-types.php with register_taxonomy for both 'postsen_category' (with slug 'category') and 'postsen_tag' (with slug 'tag'):
http://pastebin.com/8iRm0pSC

I'm using this file as a mu-plugin. I have already used "Save Changes" on /wp-admin/options-permalink.php to flush rewrite after upload the file to the server, but the links are not working.

What am I missing to make this code work?
I need some help to fix it. Tks.

[1] Logical permalink structure with custom post and taxonomies

Spidervalve100 on "woocomerce add First and Last name to customer email"

$
0
0

Hi all,

Im trying to integrate my CRM to woocomerce. My CRM lets me bcc my emails into the crm. But in order to create a person (not an email address) I need the email formated as follows:

FirstNameFromOrder LastNameFromOrder <email@fromOrder.com>

I have been able to use the following code to BCC from woocomerce, but it bcc both admin and the customer so I get multiple entries.

add_filter( 'woocommerce_email_headers', 'mycustom_headers_filter_function', 10, 2);

function mycustom_headers_filter_function( $headers, $object ) {
    if ($object == 'customer_note') {
        $headers .= 'BCC: crm@email.com' . "\r\n";
    }

    return $headers;
}

I have tried to do a few different things to get the recipients email into the format I want, but nothing works. Here is some code that did not work.

function skyverge_add_customer_to_email_recipient( $recipient, $order ) {

	$recipient .= $order->billing_first_name . ' ' . $order->billing_last_name . ' <' .  $order->billing_email . '>';
	return $recipient

}
add_filter( 'woocommerce_email_subject_new_order', 'skyverge_add_customer_to_email_recipient', 10, 2 );

I feel like I got so close, but im no programmer. Any help at all would be most appreciated.

Dave Navarro, Jr. on "Is it possible to replace an existing shortcode?"

$
0
0

One of the plugins I use has a shortcode called "display-data" and I want to extend the functionality of that shortcode.

Can I get the name of the function called for a plugin? And then disable it and replace it with my own?

So, if I use "display-data" as a shortcode, my own code gets called instead of the plugin's code AND when I manipulate the parameters, I can call the original plugin?

I know that I can just call "do_shortcode()" from within my own shortcode, but then it won't work with existing shortcodes in posts and pages.

FunMobility on "Custome URL Params directs to wrong page."

seal296 on "Pagination help"

$
0
0

I'm trying to integrate pagination on my website to replace the older/newer post navigation my theme currently uses.

The plugin instructs me to:

Replace your existing previous_posts_link() and next_posts_link() code block with the following:

[ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

<?php if(function_exists('tw_pagination'))
    tw_pagination();
?>

The problem is I'm not sure exactly what part to replace because I keep messing up. Here is the code which control the page navigation on my theme. I would appreciate if anyone can point out exactly what to replace! Thank you!

if ( ! function_exists( 'flexy_content_nav' ) ) :
/**
 * Displays navigation to next/previous pages when applicable.
 *
 * @since Flexy 1.0
 */
function flexy_content_nav( $html_id ) {
	global $wp_query;

	$html_id = esc_attr( $html_id );

	if ( $wp_query->max_num_pages > 1 ) : ?>
		<nav id="<?php echo $html_id; ?>" class="navigation" role="navigation">
			<h3 class="assistive-text"><?php _e( 'Post navigation', 'flexy' ); ?></h3>
			<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'flexy' ) ); ?></div>
			<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'flexy' ) ); ?></div>
		</nav><!-- #<?php echo $html_id; ?> .navigation -->
	<?php endif;
}
endif;

husbandman on "SVN check in failure"

$
0
0

I am using SVN for the first time. I followed the steps outlined on this page https://wordpress.org/plugins/about/svn/

I made it to this step with no problem "cd my-local-dir/"

Then I stopped for a day and came back and then ran this step "my-local-dir/$ svn add trunk/*"

That seem to work okay, but last step "svn ci -m 'My first version'" I get this
svn: E170001: Commit failed (details follow):
svn: E170001: POST of '/!svn/me': authorization failed: Could not authenticate to server: rejected Basic challenge (https://plugins.svn.wordpress.org)

I asked for my username and then password a couple of times. I know they are correct because I can log in to the forums with it to make this post.

Is there something I am doing wrong. Do I have make some sort of connection before trying to do the last step.


raviplanet on "Hacking Suspected- website shows external (redirect) links"

hkgroupadmin on "Updating to 4.2.2"

$
0
0

I have been trying to update WP for past couple of days and it keeps requesting FTP password. I enter it in but I still cannot update it due to my database files are missing. The whole entire website has changed to Twenty Eleven template.

dmccan on "Is loading wp-load.php and admin.php in your popup acceptable?"

$
0
0

I have seen plugins that include core and admin in a PHP popup. For example, when the PHP file does not otherwise have access to WP functionality, such as when included in a tinyMCE popup:

require_once('../../../wp-load.php');
require_once( '../../../wp-admin/admin.php');

Path issues aside, is it acceptable to include wp-load.php and wp-admin.php this way?

Thanks

adhoclobster on "Hacking calendar for one post per day blog"

$
0
0

I have a blog in which I post no more and no less than once per day. Every day, one post, and they're all named accordingly like this: http://everydaypoetry.net/03/31/2015/03312015/. I'm currently behind, but that's the idea.

I want readers to be able to use the calendar to open the post for any specified day. How can I hack the calendar widget so that each day on it is a link straight to that day's post?

Or is there a plugin that already exists that already does this? I haven't found one if there is, but maybe I'm overlooking one.

FreckledEgg on "Hacked Help!"

AFQ on "Get post_id in a function which runs once a day?"

$
0
0

I am creating a plugin for myself which I'll be using in conjunction with two already published in WP repository.

I am using WP Web Scrapper (https://wordpress.org/plugins/wp-web-scrapper/) to scrape some data from other websites. Now this plugin saves the WP transients API and saves the data for a certain amount of time. However, I want to save the data in a new database table so that I can access it later or manipulate it to create charts and stuff.

Now I want to run the Web Scrapper plugin once or twice every day so it fetches the data and saves it in the database. I dont know much about creating WP plugins but from what I know, you use hooks like wp_head to call your plugin function on every page (let's say for a plugin which adds a facebook button on your posts).

Since I do not need to call this plugin on every post, I only need to run it once every day? Which hook can I use?

Secondly, when the plugin function is running on every post, you can get the post ID by using the get_the_id() function or WP_post class. How can I get the post ID when the plugin isn't running on every page? I need the post ID in plugin to retrieve some post meta data which is needed to scrape the data for each post. I am putting this meta data in each using the CMB2 plugin (https://wordpress.org/plugins/cmb2/).

Thanks.

K1313 on "Logo's link"

$
0
0

Hello,
I use the qTranslate plugin to enable access to my site in Dutch and French. However, I have a problem. When I click the logo in the upper left of my site, I always arrive on the home page in the French version . How do I make when I'm on the Dutch version, so that the logo of my site takes me on the home page in Dutch?

Regards


abhibagul on "My website got some error in its .htaccess"

$
0
0

I don't know how but today i got the google bot email of not getting access and when i looked at it, the website shown me 500 error. I searched over a net but didn't got anything. Here is my code:

# BEGIN WP Rocket v2.4.1
# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset UTF-8
# Force UTF-8 for a number of file formats
<IfModule mod_mime.c>
AddCharset UTF-8 .atom .css .js .json .rss .vtt .xml
</IfModule>

# FileETag None is not enough for every server.
<IfModule mod_headers.c>
Header unset ETag
</IfModule>

# Since we're sending far-future expires, we don't need ETags for static content.
# developer.yahoo.com/performance/rules.html#etags
FileETag None

<IfModule mod_alias.c>
<FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$">
<IfModule mod_headers.c>
Header set X-Powered-By "WP Rocket/2.4.1"
Header unset Pragma
Header append Cache-Control "public"
Header unset Last-Modified
</IfModule>
</FilesMatch>

<FilesMatch "\.(css|htc|js|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$">
<IfModule mod_headers.c>
Header unset Pragma
Header append Cache-Control "public"
</IfModule>
</FilesMatch>
</IfModule>

# Expires headers (for better cache control)
<IfModule mod_expires.c>
ExpiresActive on

# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault                          "access plus 1 month"

# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
ExpiresByType text/cache-manifest       "access plus 0 seconds"

# Your document html
ExpiresByType text/html                 "access plus 0 seconds"

# Data
ExpiresByType text/xml                  "access plus 0 seconds"
ExpiresByType application/xml           "access plus 0 seconds"
ExpiresByType application/json          "access plus 0 seconds"

# Feed
ExpiresByType application/rss+xml       "access plus 1 hour"
ExpiresByType application/atom+xml      "access plus 1 hour"

# Favicon (cannot be renamed)
ExpiresByType image/x-icon              "access plus 1 week"

# Media: images, video, audio
ExpiresByType image/gif                 "access plus 1 month"
ExpiresByType image/png                 "access plus 1 month"
ExpiresByType image/jpeg                "access plus 1 month"
ExpiresByType video/ogg                 "access plus 1 month"
ExpiresByType audio/ogg                 "access plus 1 month"
ExpiresByType video/mp4                 "access plus 1 month"
ExpiresByType video/webm                "access plus 1 month"

# HTC files  (css3pie)
ExpiresByType text/x-component          "access plus 1 month"

# Webfonts
ExpiresByType application/x-font-ttf    "access plus 1 month"
ExpiresByType font/opentype             "access plus 1 month"
ExpiresByType application/x-font-woff   "access plus 1 month"
ExpiresByType image/svg+xml             "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"

# CSS and JavaScript
ExpiresByType text/css                  "access plus 1 year"
ExpiresByType application/javascript    "access plus 1 year"

</IfModule>

# Gzip compression
<IfModule mod_deflate.c>
# Active compression
SetOutputFilter DEFLATE
# Force deflate for mangled headers
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
# Don't compress images and other uncompressible content
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|rar|zip|exe|flv|mov|wma|mp3|avi|swf|mp?g)$ no-gzip dont-vary
</IfModule>
</IfModule>

# Compress all output labeled with one of the following MIME-types
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
		                          application/javascript \
		                          application/json \
		                          application/rss+xml \
		                          application/vnd.ms-fontobject \
		                          application/x-font-ttf \
		                          application/xhtml+xml \
		                          application/xml \
		                          font/opentype \
		                          image/svg+xml \
		                          image/x-icon \
		                          text/css \
		                          text/html \
		                          text/plain \
		                          text/x-component \
		                          text/xml
</IfModule>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>

<IfModule mod_mime.c>
AddType text/html .html_gzip
AddEncoding gzip .html_gzip
</IfModule>
<IfModule mod_setenvif.c>
SetEnvIfNoCase Request_URI \.html_gzip$ no-gzip
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=WPR_ENC:_gzip]
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} =""
RewriteCond %{HTTP:Cookie} !(wordpress_logged_in_|wp-postpass_|wptouch_switch_toggle|comment_author_|comment_author_email_) [NC]
RewriteCond %{REQUEST_URI} !^(/wp-json/*|.*/feed/)$ [NC]
RewriteCond %{HTTP_USER_AGENT} !^(facebookexternalhit).* [NC]
RewriteCond %{HTTPS} off
RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/%{HTTP_HOST}%{REQUEST_URI}/index.html%{ENV:WPR_ENC}" -f
RewriteRule .* "/wp-content/cache/wp-rocket/%{HTTP_HOST}%{REQUEST_URI}/index.html%{ENV:WPR_ENC}" [L]
</IfModule>
# END WP Rocket

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

I don't know anything about it. Can you help me to resolve this?

tab7x on "How to get all tags of current language?"

$
0
0

Hi,
I translated my tags using xili-tidy-tag and I wrote this PHP code that return all tags

<?php
if( is_page_template( 'my-page-template.php' ) || is_tag() )
{
	$tags = get_tags();
	$current_tag=get_query_var('tag');
	$html = '<ul class="posts-by-tag-list">';
	foreach ( $tags as $tag ) {
		if($tag->name == $current_tag) {
			$class = ' class="current_tag_item"';
		}
		else
			$class = '';
		$tag_link = get_tag_link( $tag->term_id );

		$html .= "<li ".$class."><a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
		//$html .= "{$tag->name}</a></li>";
		$html .= ucfirst($tag->name)."</a></li>";
	}
	$html .= '</ul>';
	echo $html;
}
?>

How can I get only tags of selected language?
Thanks

Nomi on "Register Widget Areas from Custom Widget"

$
0
0

Is this possible to register sidebar / widget area from a custom widget?. If you have any idea please let me know.

I can create it from custom theme and custom plugin. But I want to create from widget.

muesly_lover on "custom user form which let the user choose password"

$
0
0

Hi everyone,

I finally create an interactive login form on a page which let the user log in, register or ask for a new password, while staying on the current page.
(I need this since I modify the woocommerce process:
cart -> log in / register -> checkout -> pay )

Not easy for me :'(

Here the thing :
To finalize it, I need to add a password field to the register form I create. so the customer choose his password, auto login (email sent) and arrive on the checkout page. (amazon style!)
Since I copy an existing one I tweak a bit, I just don't know how to do it.

Here my code :

<div class="tabs_login">
		<p id="lien_login">Connexion</p>
		<p id="lien_register">Inscription</p>
		<p id="lien_lost">Mot de passe oublié</p>
    </div>

	<div class="tab_container_login" style="text-align:center;">
		<div id="tab1_login" class="tab_content_login">
            <h4 style="text-align: center;font-size:16px;font-weight:bold;padding-bottom:15px;">Connexion</h4>
			<?php $register = $_GET['register']; $reset = $_GET['reset']; if ($register == true) { ?>

			<h3 style="padding-bottom:15px;">Enregistrement réussi!</h3>
			<p style="padding-bottom:15px;">Votre mot de passe vient de vous être envoyé à l'adresse mail renseignée.</p>

			<?php } elseif ($reset == true) { ?>

			<h3 style="padding-bottom:15px;">Demande enregistrée!</h3>
			<p style="padding-bottom:15px;">Votre nouveau mot de passe vient de vous être envoyé à l'adresse mail renseignée.</p>

			<?php } ?>

			<form method="post" action="<?php bloginfo('url') ?>/wp-login.php" class="wp-user-form">
				<div class="username">
					<label for="user_login"><?php _e('Identifiant'); ?>: </label>
					<input type="text" name="log" value="<?php echo esc_attr(stripslashes($user_login)); ?>" size="20" id="user_login" tabindex="11" />
				</div>
				<div class="password">
					<label for="user_pass"><?php _e('Mot de passe'); ?>: </label>
					<input type="password" name="pwd" value="" size="20" id="user_pass" tabindex="12" />
				</div>
				<div class="login_fields">
					<div class="rememberme">
						<label for="rememberme">
							<input type="checkbox" name="rememberme" value="forever" checked="checked" id="rememberme" tabindex="13" /> Rester connecté
						</label>
					</div>
					<?php do_action('login_form'); ?>
					<input type="submit" name="user-submit" value="<?php _e('connexion'); ?>" tabindex="14" class="user-submit" />
					<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" />
					<input type="hidden" name="user-cookie" value="1" />
				</div>
			</form>
		</div>
		<div id="tab2_login" class="tab_content_login" style="display:none;">
			<h4 style="text-align: center;font-size:16px;font-weight:bold;padding-bottom:15px;">Créer un compte</h4>
			<form method="post" action="<?php echo site_url('wp-login.php?action=register', 'login_post') ?>" class="wp-user-form">
				<div class="username">
					<label for="user_login"><?php _e('Identifiant'); ?>: </label>
					<input type="text" name="user_login" value="<?php echo esc_attr(stripslashes($user_login)); ?>" size="20" id="user_login" tabindex="101" />
				</div>
				<div class="password">
					<label for="user_email"><?php _e('Email'); ?>: </label>
					<input type="text" name="user_email" value="<?php echo esc_attr(stripslashes($user_email)); ?>" size="25" id="user_email" tabindex="102" />
				</div>
				<div class="login_fields">
					<?php do_action('register_form'); ?>
					<input type="submit" name="user-submit" value="<?php _e('Créer mon compte'); ?>" class="user-submit" tabindex="103" />
					<?php $register = $_GET['register']; if($register == true) { echo '<p>Votre mot de passe vous a été envoyé à votre adresse mail.</p>'; } ?>
					<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>?register=true" />
					<input type="hidden" name="user-cookie" value="1" />
				</div>
			</form>
		</div>
		<div id="tab3_login" class="tab_content_login" style="display:none;">
			<h4 style="text-align: center;font-size:16px;font-weight:bold;padding-bottom:15px;">Mot de passe perdu</h4>
			<p style="padding-bottom:15px;">Entrer votre pseudo ou votre email afin de recevoir un nouveau mot de passe</p>
			<form method="post" action="<?php echo site_url('wp-login.php?action=lostpassword', 'login_post') ?>" class="wp-user-form">
				<div class="username">
					<label for="user_login" class="hide"><?php _e('Username or Email'); ?>: </label>
					<input type="text" name="user_login" value="" size="20" id="user_login" tabindex="1001" />
				</div>
				<div class="login_fields">
					<?php do_action('login_form', 'resetpass'); ?>
					<input type="submit" name="user-submit" value="<?php _e('Nouveau mot de passe'); ?>" class="user-submit" tabindex="1002" />
					<?php $reset = $_GET['reset']; if($reset == true) { echo '<p style="padding-top:15px;">Un email vous sera envoyé.</p>'; } ?>
					<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>?reset=true" />
					<input type="hidden" name="user-cookie" value="1" />
				</div>
			</form>
		</div>
	</div>

and if you wanna test it in action, you need to go to my website, add to cart something then go through the order process (but the site is in french only (french book) so it could be disturbing): google : "Edition le héron d'argent" to find it.

Thanks in advance.

At your service for any questions, suggestions

Another Guy on "Pre-login hook for filtering code"

$
0
0

I have a routine that I have installed on wordpress sites which filters out incoming requests for things like wp-login, /wp-admin, and so on. The code runs BEFORE any of the wordpress core, to limit server load from undesirables who may be trying to access the site. I created this code because any site that operates with something like cloudflare or other similar systems are not able to generally filter by htaccess.

I add the code in at line 10 of wp-login, as an example, and can redirect or decline people trying to log in from places and IPs that I do not accept to access the admin area. It greatly cuts down on the brute force attacks on the server.

For the moment, I have to manually re-add the code during every version update, because there is no hook point within wordpress to handle this. Is there a way to have wordpress check for the existance of a "security.php" or whatever file which could be used to help cut down on unwanted attempts to access the core?

Remember, not everyone can filter with htaccess (for different reasons).

Viewing all 8245 articles
Browse latest View live




Latest Images