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

cyberlp23 on "Prevent posting when no category is selected"

$
0
0

Hello,

I'm trying to trigger an action if, when a user tries to publish a post, no category is selected:
- It could either be just an alert message (and the post is still published);
- Or actually alter message + preventing the post from being published.

Searching on this forum, I've found the code:

jQuery('#submitdiv').on('click','#publish',function(e){
            var $checked = jQuery('#category-all li input:checked');
            if ( $checked.length <= 0 ) { //Checks if cat is selected
            alert("Please Select atleast one category");
            return false;
            }else{ //Else continue
                return true;
            }
            });

But I have no idea where to put it.

Thanks!


gab81 on "Redirect uppercase to lowercase in .htaccess"

$
0
0

​hi,

I'd like to redirect uppercase to lowercase in .htaccess so say I have domain.com/Contact, that should go to domain.com/contact

all urls within the website are lowercase but you never know someone might link in uppercase... I saw many solutions but is there a good one working?

thanks

bigdropgr on "Show related posts on single custom post page by custom taxonomy"

$
0
0

Hello, I have two custom post types, one named "villa" and the other one "destinations". I have used the CPT-onomies plugin to make the "destinations" custom post type a custom taxonomy for my "villa" post type. Now I want on each single-villa.php to show one related villa in the end of the post (after the loop) using only the custom taxonomy "destinations".

I googled it a lot and found this article, I followed the instructions and it somehow did the trick for me, unfortunately I cannot figure out two things: 1. First I dont know how to make it show only one related villa (post) instead of all the related posts. 2. I dont know how to to exclude the current post from related posts (there are instructions on how to achieve that on the article I have linked to above but it doen't work for me.

I dont want to use any plugin, instead I want to add some code to my theme to do that.

Thank you all in advance for your time and answers!

giu1io on "get_avatar() returns an url with #038; instead of &"

$
0
0

In the latest WordPress something has changed in the get_avatar() function because the output has changed and it's no longer correct. Note that in 4.1.x everything was just fine.
Now when i call the function get_avatar like this:

$astring = get_avatar($author,$size);

I get this as output:

<img alt='' src='http://2.gravatar.com/avatar/5ccf704664de0bbc2b633b2e550a1e1a?s=100&d=wavatar&r=g' srcset='http://2.gravatar.com/avatar/5ccf704664de0bbc2b633b2e550a1e1a?s=200&d=wavatar&r=g 2x' class='avatar avatar-100 photo' height='100' width='100' />

as you can see the url in src has "&" instead of "&". Instead the url in srcset it's correct.
Why does this happen? Am I doing something wrong? It's a WordPress bug?
I have temporarily fixed the problem with a preg_replace but it don't like it as a permanent solution.

EDIT: sadly for some reason the support forum replaces & with & in the code block (really funny) so you can't see of what I am talking about. Just take a look at this screenshot please.

Travel Girl 2 on "Sidebar Custom Menu Widget Hacked & Won't Work on Sidebar"

$
0
0

My Sidebar Custom Menu Widget has been hacked and now includes a requirement for me to select which Menu (Menu 2, which is horizontal and up top, and Social (Social media) I want it attached to. I know this was done to prevent me from using it for ads. Is there a way to fix this? Not sure if it is part of Jetpack or Wordpress, but I guarantee what I am saying is correct. At least at the moment I am writing this.

Another example of hacking (by a government agency): My 3-column widgetized footer keeps switching around all by itself. On one page, it will be the correct order; on another page, it won't. Right now, all three columns are on the right side, one after another...Without me doing anything!

BTW, this is also being done to discredit me. As soon as I have posted other, similar problems, they fix themselves magically...in the hopes that those who read these posts will think I'm crazy. No lie. When my blog is finally up and running, everyone will know that a crazy person could never have put it together. But the Fancy Boy Idiots are doing whatever they can to stall it.

My site is still under construction.

Fgarcia1986 on "was recently hacked and i inadvertently ruined my website"

$
0
0

i was recently hacked and my website was filled with malicious code.

i went in to each file that had malicious code to see if the file was entirely malicious or if just segments.

i deleted the files that were completely malicious, and i deleted the code from the files such as functions.php

as my site came back online it appears to be completely blank. i have not backed up any sites so is there any way to go back in time via wordpress to re-upload prior to the infection?

Nilambar Sharma on "About sanitizing hex color [sanitize_hex_color]"

$
0
0

I was looking for sanitizing HEX color value. I found function sanitize_hex_color and it is included in class-wp-customize-manager.php. Why is that function kept in there? I am trying to use it in my theme but it says function not found.

bahrui5912 on "importing php files from custom built php site new wordpress template"

$
0
0

Hello! I need help with the transferring php files into wordpress. I have already imported mysql database to new wordpress template. But we need to keep same functions from the older site, but I don't know how to transfer the php files into wordpress. Thanks!


cyberlp23 on "Remove a parent theme include?"

$
0
0

Hello,
My parent's theme has a line (not part of a function):
include (get_template_directory().'/includes/widgets/file.php');
Is there a way not to include this file, using the child theme?
Thanks.

Yooshii1 on "Support to develope a working contact form 7"

$
0
0

Hi guys!

I would need some help here to create a working and a good lucking contact form 7. This is something new for me and i'm not sure what it is im doing wrong or right hehe..

Please help me out if you can i would apreciat it.. I'm in big need to launch my site. I have drawed up it up for you guys so you can understand me becuse im not so good with the coding terms, And i have also added the simple code im using for now

Thank you for reading it,

|-----------------Favoure colure------------------------|

|------Name-------| |-------Phone-------------|

|------Email------| |----Favoure item---------|

|---picture of item-----|

|-------------Messege here-----------------------------|
|------------------------------------------------------|
|------------------------------------------------------|
|------------------------------------------------------|

|---- Send now------|

<p>Favoure colure<br />
    [select menu-56 "Red" "Blue" "Green"] </p>

<p>Name*<br />
    [text* your-name] </p>

<p>Phone<br />
    [tel tel-306 /10] </p>

<p>E-mail*<br />
    [email* your-email] </p>

<p>Favourite thing in that colure<br />
    [text text-636] </p>

<p>Picture of that item<br />
    [file file-505 limit:30 filetypes:JPG|JPEG|GIF|PNG|GIF]</p>

<p>Text about your item<br />
    [textarea your-message] </p>

<p>[submit "Send"]</p>

https://wordpress.org/plugins/contact-form-7/

luciole135 on "Is unnecessary to optimize InnoDB tables?"

$
0
0

Hello
Since MySQL 5.5.5, database tables newly created are in InnoDB by default.
"OPTIMIZE TABLE" query does not work on these tables.
I have hearsay that the InnoDB tables did not need to be optimized!
Is this true?
Is unnecessary to optimize InnoDB tables?

Rickiet on "Forgotten my URL to login into WordPress"

wpbegin1122 on "how to get rid of Performance plugin a hack automatically installed in wordpress"

$
0
0

Hi I believe many bloggers are facing this same problem.
My blog is hacked my a plugin named performance. I did not install that plugin. It is slowing the speed. This appears after the setting buttons in the left menu.
Can anyone please help me how to get rid of this hack plugin?
Thanks.

CodeMonkeyBanana on "Is this a bug/inconsistency or operator error?"

$
0
0

I am trying to remove some ajax actions that a plugin adds but for ajax actions, once they are added they cannot be removed.

I went round in circles for a while then tried just doing this with a test function:

add_action('wp_ajax_nopriv_ajax_test', array(&$this, 'ajax_test'));
        add_action('wp_ajax_ajax_test', array(&$this, 'ajax_test'));
        remove_all_actions('wp_ajax_nopriv_ajax_test');
        remove_all_actions('wp_ajax_ajax_test');

This test function is available through javascript on front end even though it is removed immediately after its added.

I realise that the ajax actions must work differently as there is no hard coded do_action. I tried stepping through the code of add_action but I could not see anything different.

I really need to be able to disable certain plugins ajax hooks but I cannot find a way.

Am I doing something wrong or is this a bug?

Shaped Pixels on "How to remove the Next & Prev out of the post nav link?"

$
0
0

With the_post_navigation(), how can I get the "Next" and "Prev" out of the link so that it becomes a text based label, followed by the linked post title?

Example of current "Next" nav:

'next_text' => '<span class="meta-nav" aria-hidden="true">' . __( 'Next', 'mytheme' ) . '</span> ' .
'<span class="screen-reader-text">' . __( 'Next post:', 'mytheme' ) . '</span> ' .
'<span class="post-title">%title</span>',

I'm sure there's a way to do this without making a really ugly hack, but I'm not finding a good solution. Basically I'm looking to do this:

Next: This is the next post title

....but not this:

Next: This is the next post title


deelind on "I want, I need, want need these changes."

$
0
0

I have the changes here for anyone ambitious enough to help me out, slowly learning and happy to have gotten as far as this. What I would like is illustrated here

I've tried to change the color of the menu text from green to gray, stumped. I'd be happy just to have the green off the page.

Thanks so much, dee

carlsandburg on "question about add_action"

$
0
0

I'm modifying an existing plugin which has a routine - AddHeaderContent - that adds some javascript code that displays rotating quotes. The main code has the line below, which i think adds the javascript (and the quotes) to every page.

add_action('wp_head', array(&$quoteRotator, 'addHeaderContent'));

It works, but doesn't seem very efficient. It would be better to only do it when the shortcode exists on the page.

Any ideas on how to do that/if possible. Must be, right?

thanks for your time.

Team143 on "Get User posted Content from wordpress to Other website using Ajax request"

$
0
0

I have one wordpress and other HTML website. In my wordpress contain user posts. I need to get the content from wordpress site to my HTML website using AJAX request.

I will pass user email Id through the AJAX request ,from this request i need to get the specified user posted content from wordpress. Is it possible.Please suggest the better option.

chriswindsor on "Change user role based on account spend woocommerce"

$
0
0

Hello. I have been working on an issue for a little while and can't seem to find the solution. I am attempting to develop a function that changes a customer's account type (ie from 'customer' to something else) once their account spend hits a certain amount.

Here is what I have tried so far. I very new to writing php and functions so I apologize upfront for the mess this may be. Any help would be appreciated.

/**
 * Get total spent by customer
 * @param  int $user_id
 * @return string
 */
function wc_get_customer_total_spent( $user_id ) {
if ( ! $spent = get_user_meta( $user_id, '_money_spent' < 50 ) ) {
global $wpdb;
 // Remove role
        $user->remove_role( 'customer' );

        // Add role
        $user->add_role( 'procon' );

$spent = $wpdb->get_var( "SELECT SUM(meta2.meta_value)
FROM $wpdb->posts as posts

LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
LEFT JOIN {$wpdb->postmeta} AS meta2 ON posts.ID = meta2.post_id

WHERE   meta.meta_key       = '_customer_user'
AND     meta.meta_value     = $user_id
AND     posts.post_type     IN ('" . implode( "','", wc_get_order_types( 'reports' ) ) . "')
AND     posts.post_status   IN ( 'wc-completed', 'wc-processing' )
AND     meta2.meta_key      = '_order_total'
"

        );

update_user_meta( $user_id, '_money_spent', $spent );
}

return $spent;
}

luciole135 on "Impossible to optimize an InnoDB data table with the $wpdb class?"

$
0
0

Hello
To optimize an InnoDB table, just run a query in the phpMyAdmin SQL tab. (for example):

ALTER TABLE wp_posts ENGINE = InnoDB

And it work !

But when you run this same query with the $wpdb class, it does not work!

$result = $wpdb-> query('ALTER TABLE '.$table_name->Name.') ENGINE = InnoDB');

How do I optimize an InnoDB table with the $wpdb class?

Viewing all 8245 articles
Browse latest View live




Latest Images