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

spasarok on "List of Default Customizer Controls"

$
0
0

I'm working on a variant of the Twenty Eleven theme and am currently tweaking the Customizer. I'd like to move the Header Text Color control from the Colors section to the Site Title & Tagline section.

I know that I can do this with the Link Colors control using the code:

$wp_customize->get_control( 'link_color'  )->section   = 'title_tagline';

Here link_color indicates the control. What do I have to use to indicate the Header Text Color control? Is there a reference list of all the default controls?


Polytee on "Woocoormerce Price Change"

$
0
0

Hi

Can you please help me with how i can change the price of an order based from a calculated inputbox, for example width*height = total, Total should be a standard price of the order and add it to cart with it as well as get the orders with the calculated price.

Im using woocormerce for this and im done with the site but cant seem to add it to the order , Thanks

xvegax on "Custom Gallery showing only 5 images instead all"

$
0
0

Hi guys,

With someone's help I created a custom gallery script, which is loading all images with a certain "slug", e.g. "people", "scenery", ...

It does work with one exception: It shows only five pictures and does not show the rest ... and I just can not find the culprit for that. :(

Here is an example website: studio-scs.de/people.

Here is my code:

<?php
/**
* Template Name: Scenery Gallery
*/

get_header(); ?>

 <h2 class="gross"><?php the_title(); ?></h2>

 <div id="inhalt">

 <div class="entry">

 <?php

    $scenery_attachments = new WP_Query( array(
    'post_type' => 'attachment',
    'post_status' => 'inherit',
    'posts_per_page' => 0,
    'category_name' => 'scenery', // note: use category SLUG
    ) );

    $scenery_id_array = array();

    if ( $scenery_attachments->have_posts() ) : while ( $scenery_attachments->have_posts() ) : $scenery_attachments->the_post();

    $scenery_id_array[] = get_the_ID();

    endwhile; endif;
    // Important!
    wp_reset_postdata();

    $scenery_ids = implode( ',', $scenery_id_array );

    echo do_shortcode( '[gallery link="file" columns="5" order="DESC" orderby="ID" include="' . $scenery_ids . '"]' );

 ?>

 </div>

 <?php // get_sidebar(); ?>

<?php get_footer(); ?>

Someone sees what is wrong? Apart from showing not all pictures, it seems to work just fine.

xvegax on "Custom gallery needs a navigation/pagination"

$
0
0

With someone's help I created a custom gallery script, which is loading all images with a certain "slug", e.g. "people", "scenery", ...

It does work fine now for some unknown reason I just do not get the navigation/pagination to work and I really would like to have only 9 pictures per page for example or whatever value fits the needs.

Here is an example website: studio-scs.de/people.

Here is my code:

<?php
/**
* Template Name: Scenery Gallery
*/

get_header(); ?>

 <h2 class="gross"><?php the_title(); ?></h2>

 <div id="inhalt">

 <div class="entry">

 <?php

    $scenery_attachments = new WP_Query( array(
    'post_type' => 'attachment',
    'post_status' => 'inherit',
    'posts_per_page' => 99999,
    'category_name' => 'scenery', // note: use category SLUG
    ) );

    $scenery_id_array = array();

    if ( $scenery_attachments->have_posts() ) : while ( $scenery_attachments->have_posts() ) : $scenery_attachments->the_post();

    $scenery_id_array[] = get_the_ID();

    endwhile; endif;
    // Important!
    wp_reset_postdata();

    $scenery_ids = implode( ',', $scenery_id_array );

    echo do_shortcode( '[gallery link="file" columns="5" order="DESC" orderby="ID" include="' . $scenery_ids . '"]' );

 ?>

 </div>

 <?php // get_sidebar(); ?>

<?php get_footer(); ?>

Does anyone know how to add the pagination without using a plugin? I tried like four plugins and they just did not work fine here.

randomshinichi on "How to return a WP_Error for OTP authentication?"

$
0
0

In my plugin I have the following code:

add_action('wp_authenticate','filmcustom_otptoken_authenticate');
function filmcustom_otptoken_authenticate($username){
	$otpresult = $_POST['otptoken'];
	$user = get_user_by('login',$username);
	$shouldbe = filmcustom_otptoken_validate($username);
	if (!$user||$shouldbe!=$otpresult) {
		remove_action('authenticate', 'wp_authenticate_username_password', 20);
        $user = new WP_Error( 'denied', __("<strong>ERROR</strong>: You need an OTP.") );
	}
	return $user;
}

However, when I put the wrong OTP in, it doesn't say "ERROR: You need an OTP", it says "ERROR: Invalid username or incorrect password." What am I doing wrong here?

LPH2005 on "wp_set_auth_cookie, external user logs into WP but cannot publish"

$
0
0

Hello,

Ever since 4.0 beta 2, WP turned on the feature for tying cookies and sessions together. Now plugin code that used to work for logging in an external user fails to allow the user (with correct permissions / roles ) to publish a post. The user can post a comment but cannot publish a WP post or page.

The error returned is "are you sure you want to do this?"

Code:

$visitor = $XF->visitor;
$user_ID = $visitor->get( 'user_id' );
wp_set_auth_cookie( $user_ID, 0, 0 );

Again, this code worked fine for years with previous versions but stopped with 4.0 beta 2 release. The user is logged into WP. It is the publish a post or page that fails.

Any suggestions on how to re-write the code?

Is this a problem in wp_verify_nonce?

Sonja on "Standard for case of table names ?"

$
0
0

Is there a Standard for the case of MySQL table names ?

rohan1819 on "Links not working correctly."

$
0
0

I am creating website for one of my client and when i give link to some text pointing to some different url its opening my site url and linked url also, suppose if link some word to http://www.google.com its not opening as http://www.google.com. its opening as "http://mysiteurl/\www.google.com" and showing 404 error


Reuven.g on "Disable the javascript function wp_attempt_focus() in wp-login"

$
0
0

Near the end of the wp-login.php file there is a definition of a javascript function wp_attempt_focus() which do autofocus on on the inputs on a timeout.
I want to disable it and prevent it from firing.
Is there any possible way to do so without changing the wp-login.php
file?
I have tried adding javascript to the login_footer action hook,
setting the inputs to blur.
It removes the focus on the input but it is done after focusing on the input, which I want to prevent from happening.
Is there a way to do this without deleting the function from the wp-ogin.php file?

otti.steinhauer on "send sms from wordrpess"

$
0
0

Hello,

actually I create another plugin. And there is one function I cannot find out how to code it.
There is a form with a field to get a sms-number and a button to send this form, that's OK.
Now I want to send a sms when the button is clicked. For that, I want to create an function like

send_sms($sms){
$message ="myMessage";}

And now I don't know what to do to get $message as sms to $sms. Is there a function like wp_mail()?

Thanks

Ottilie

pavzcap on "automatically duplicate post template changing certain key variables"

$
0
0

Hi All,

I am new to this forum and have just embarked on my wordpress journey.

I was wondering if I could get some help on something I am trying to achieve. I am basically making posts on the FTSE 100 companies, each basic post follows the same generate template for each company, namely:

[su_heading]CompanyName[/su_heading]

[su_button url="http://www.CompanyName.com" target="blank" background="#1f8e2a"]ZDG plc site[/su_button]

[google_news query='"CampanyName"' sort="n"]

Essentially a header for the company, a button linking to their website and a google feed showing the news for the company. Beyond this each post will be tailored.

I was wondering if there is any way that I can automatically generate 100 posts and change the variable 'CompanyName' with a given name from a list, possible via a loop function? I am very new to php and am thinking in terms of VBA which I am far more familiar with. Is anything like this possible? It would save a lot of tedious time rather than copy and pasting manually. Can I build a plugin to do this?

Any help on this issue would be much appreciated. Please ask me any questions if I have not been clear in what I am trying to achieve.

Thank you in advance

gezelligenleuk on "Serious site hack attack"

$
0
0

Specs:
website:www.gezelligenleuk.nl
wordpress: 3.9.2
theme: Studiopress Genesis with News-Pro childtheme

Hello,

My website has been hacked. My website is about art, but someone added 6 pages to my site linking to casino- and gambling websites.
Webmasters Tools shows that 55.000 (!!!) casino-websites are linking to my site. Needless to say that this is disastrous for my ranking in Google.

I tried everything to get rid of the links. The strange thing is, there are 6 pages added but I can NOT see them in my Wordpress-admin, as if they don't
exist. They all look like this: /?p=online-casino-uk

This is what I've tried so far:

- Re-installed Wordpress, I even bought a total new fresh copy of the Studiopress News-Pro childtheme.
- Changed all passwords
- Deleted and re-installed all plugins
- Wrote a robot-txt file to tell Google not to index the 6 casino-pages
- Sent a request to Google to ignore the 55.000 links
- Found and removed at least 1 malicious file in php-admin (could not find more)
- Installed and tried many security plugins like WordFence (they could not find anything)

Some of these actions were successfull, but everytime the casino links keep coming back. What I find very strange is that I completely removed my old
version of the New-Pro theme and installed a fresh copy which I just purchased. How can the links come back?
It's as if this virus operates from outside.

Is there somebody here who knows the answer to this problem? Anyone having the same experiences?

These are the links:
/?p=online-gambling
/?p=casino-bonus
/?p=online-casino-uk
/?p=online-casinos
/?p=online-casino-usa
/?p=mobile-casino

Paul

golden_zenith on "Lightboxes and advanced custom fields"

$
0
0

Sorry in advance for the long post, but I've read just about everything out there on this topic and no dice. I want to make a custom lightbox and use it to display a person's name, image, and brief bio, with a dark gray overlay. So far I have this:

<?php
	$args = array('post_type' => 'team');
	$the_query = new WP_Query($args);
?>

<div id='imagegallery'>
<?php if ( have_posts() ) :
	while ( $the_query->have_posts() ) :
		$the_query->the_post(); ?>
		<a href="javascript:void(0)" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block';">
			<div class="member">
				<div id='member-img'><img src='<?php the_field('image'); ?>' alt='<?php the_field('name'); ?>' /></div>
				<div id='member-name'><?php the_field('name'); ?></div>
			</div>
		</a>

                <!-- Frustrating chunk of evil -->
		<a href="javascript:void(0)" onclick="document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">
			<div id="light" class="lightbox">
				<?php the_field('name'); ?>
				<img src="<?php the_field('image'); ?>" alt="<?php the_field('name'); ?>" />
				<?php the_field('description'); ?>
			</div>
			<div id="fade" class="overlay"></div>
		</a>
<?php endwhile; endif; ?>
</div>

There are a couple problems with this:

1) The imagegallery div contains all member divs, but it also contains the lightbox, which is not good because everything is squished in one parent div and has scrollbars all over the place. The lightbox should be essentially in the middle of the page, not the imagegallery div. I know this could be easy to fix, but that leads me to the next problem...

2) No matter which member div I click on, the lightbox that appears has all the information from the first member div. I understand this is because of the placement of my frustrating chunk of evil but if I move it outside the loop, then the lightbox that shows up only remembers the info from the last member div, which is essentially the same issue.

Is there any way I can access the field data outside of the WordPress Loop and use it to create a lightbox that shows up when I click on the corresponding member div?

hmoore71 on "Help testing plugins"

$
0
0

I am developing three plugins and would appreciate beta testing help for these plugins. One is a Full Calendar V2 implementation. The second is a email reader and posting plugin. The third is a map editor.
The cursory documentation is here.
I am planning to move these plugins to the Wordpress repository after they are internationalize.
Please use the contact form on the website to contact me if interested.

Thanks

SBlancher on "User set_role setting role to 'None'"

$
0
0

Hello Hack Community!

So I have a very odd scenario, but first let it be known I'm using the plugin Role Manager (found here). I realize this could entirely be the issue but I've tried deactivating it and running my code and it still does not work.

Full Scenario: I've created a function (in functions.php) to fire after a customer buys a membership product. I need their role elevated after payment is received.

So my problem is that when I am using the set_role function to change a users role to a custom one I've created, it doesn't completely work. It actually sets the users role to 'None'. Under the edit page of that user it further defines this as 'No role for this site'. Even more odd it just happens to list the user under the custom role I created! Further testing proved that if I even use set_role to change the user role to 'Administrator', it once again sets the user role to 'None' but LISTS THE USER UNDER ADMINISTRATORS. Very peculiar. This means they are listed properly but have none of the capabilities of the role.

Here is my usage of set_role in my function:
global $current_user;
get_currentuserinfo();
$wp_user_object = new WP_User($current_user->ID); //not used
$current_user->set_role(SisterhoodMember);

I was using a WP_User object before but it was the same as using $current_user so I went with the more direct route. Can anyone help me out with this?? Is it the plugin? I really would like to keep it, my client has been using it for quite a while.

If the full function is necessary I will post it, I'd rather not but I will if necessary. Thank you to anyone who can help me!!


guy.joseph on "Running JQuery onclick"

$
0
0

Hi

I have very little experience with web development but a reasonable experience with Windows .Net development. Apologies therefore if any of this is a bit silly.

I have got this JSFiddle which is working perfectly, but I'm now trying to 'port' it over to a wordpress plugin.

I have my plugin below. Essentially I am taking the code in the fiddle and running a for/each over a GravityForms property to generate x number of different input boxes. By pressing the add another link a new set of identical boxes should be added, and removed with their respective remove link.

I am unable to get the add/remove code to actually run. All that happens is that the page reloads to the top... I know that's because of the href="#" bit.

So I'm pretty sure that I've done something stupid, but if somebody could point out what I've done that would be very much appreciated. The Java code from the JSFiddle is located in the /gf-repeater-field/js/repeaterJS.js file, copied exactly from the Fiddle. I don't care if it's a button, link or image that the user presses. It would be preferable if it didn't reload to the top of the page.

Thanks for your help!

<?php
function gf_repeater_scripts() {
	wp_enqueue_script( 'repeaterJS',  plugins_url() . '/gf-repeater-field/js/repeaterJS.js', '', '1.0.0', false );
}

add_action( 'wp_enqueue_scripts', 'gf_repeater_scripts' );

function phpAlert($msg) {
    echo '<script type="text/javascript">alert("' . $msg . '")</script>';
}

// Add a custom field button to the advanced to the field editor
add_filter( 'gform_add_field_buttons', 'gf_add_repeat_field' );
function gf_add_repeat_field( $field_groups ) {
    foreach( $field_groups as &$group ){
        if( $group["name"] == "advanced_fields" ){
            $group["fields"][] = array(
                "class"=>"button",
                "value" => __("Repeater", "gravityforms"),
                "onclick" => "StartAddField('repeater');"
            );
            break;
        }
    }
    return $field_groups;
}

// Adds title to GF custom field
add_filter( 'gform_field_type_title' , 'gf_repeat_title' );
function gf_repeat_title( $type ) {
    if ( $type == 'repeater' )
        return __( 'Repeater' , 'gravityforms' );
}

// Adds the input area to the external side
add_action( "gform_field_input" , "gf_repeat_input", 10, 5 );
function gf_repeat_input( $input, $field, $value, $lead_id, $form_id ){

if ( $field["type"] == "repeater" ) {

        $id = $field["id"];
        $field_id = IS_ADMIN || $form_id == 0 ? "input_$id" : "input_" . $form_id . "_$id";
        $form_id = IS_ADMIN && empty($form_id) ? rgget("id") : $form_id;

        $has_columns = is_array(rgar($field, "choices"));
        $columns = $has_columns ? rgar($field, "choices") : array(array());

				// Start building control

				$repeater = "";
                $repeater .= "<div class='repeatingSection' style='border: 1px solid black; padding: 5px; margin: 5px;'>";

                foreach($columns as $item){
					$myName = $item["text"];
					$myValue = $item["value"];

					$repeater .= "<div class='formRow' style='padding: 2px;'>";				//Begin formRow

					$repeater .= "<label for='" . $myValue . "_1'>";
					$repeater .= $myName;
					$repeater .= "</label>";

					$repeater .= "<input type='text' name='";
					$repeater .= $myValue;
					$repeater .= "_1' id='";
					$repeater .=  $myValue ;
					$repeater .= "_1' value='' />";
					$repeater .= "</div>";													//End formRow
                }

				$repeater .= "<a href='#' class='deleteSection'>Delete</a>";

				$repeater .= "</div>";														//End repeatingSection

				$repeater .= "<div class='formRowRepeatingSection'> <a href='#' class='addAnotherSection'>Add Another</a></div>";

                return $repeater;
}
}

Dean Lederle on "Site hack and links injected"

$
0
0

Hi There,

We've recently been under attack by a hacker named "adolo" who managed to gain access to our site and then add links to the head of our website which we are unable to remove as we cannot locate where the links were embedded.

The website is: http://www.sondela.com/ and the links inserted were as follows:
cheap Accutaneampicillin online

The website generates quite a lot of traffic and we can't afford to have spam links on all the pages.

Any advice would be greatly appreciated.

Dean

andy3000 on "Adding page breaks to long content archive"

$
0
0

I did some work on a site with an archive page that displays way too much content so it loads too slowly. It should really be split up into a bunch of pages the way the categories display in most themes. I wanted to study how category pages do this so I could modify the page template.I have looked at a few category templates from different themes but I don't see the code that does this. Is it in the core? Can some one point me to where to look for it?

keh3084 on "Change post template via url parameter"

$
0
0

I needed to serve up the post content only.
Everything else, including the header, footer and the sidebars needed to be stripped out.
I needed this ‘post content only’ version to be always available, for every post, but for the original fully styled posts to be available as well.

And I found this!!
http://scratch99.com/wordpress/development/how-to-change-post-template-via-url-parameter/

I added the following code to my theme's functions.php file:

function sjc_add_query_vars($vars) {
    return array('template') + $vars;
}
add_filter('query_vars', 'sjc_add_query_vars');

function sjc_template($template) {
  global $wp;
  if ($wp->query_vars['template']=='basic') {
    return dirname( __FILE__ ) . '/single-basic.php';
  }
  else {
    return $template;
  }
}
add_filter('single_template', 'sjc_template');

And I created a file called single-basic.php, then added the following code.

<div id="content">
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
          <h2 class="item"><span class="fn"><?php the_title(); ?></span></h2>
        <?php the_content(); ?>
    <?php endwhile; else: ?>
    <?php endif; ?>
</div>

But It didn't work!
(http://domain.com/postname/?template=basic) is still blank page.
Please help me...

Medesko on "get_previous_post in two categorie"

$
0
0

Hello!
I have a post in two categories, A and B.
I check by term and i m in categories A i want to get the previous post in for categories not for two.

Thank for help

Viewing all 8245 articles
Browse latest View live




Latest Images