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

webeno on "Authentication Cookie to be extended with every page load"

$
0
0

I'm trying to change the auth cookies so that they extend with every page load but therefore I'd also set them for a much shorter time, say 15 mins, much like it's needed for web apps for example (which is how I intend to use the portion of wordpress I'm going to use this for).

Ideally I would want to do this the JS way too to extend the cookie time with every mouse click and keystroke, so if you have ideas in doing so, it's very much welcome too.

What I tried, the PHP way - the problem with this one is that it logs me out every time I reload the page (added this to functions.php) - one of the things I'm a bit unsure about in this code is the arguments of wp_set_auth_cookie:

/* Renew cookie at every page load */
function renew_wp_cookie() {

    global $current_user;
    get_currentuserinfo();
    $userinnow = $current_user->user_login;
    if (is_user_logged_in()) {
        wp_set_auth_cookie($userinnow, $remember, $secure);
    }
    else wp_clear_auth_cookie();

}

add_action('init', 'renew_wp_cookie');

On the JS front, I have found following function in one of the .js files provided with my theme - I may make some use of it, not sure yet how:

function setCookie(c_name,value,expiredays)
{
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = c_name + "=" + escape(value) +
	((expiredays==null) ? "" : ";expires=" + exdate.toGMTString()) + '; path=/';
}

bramwittendorp on "MySQL database installation is not working"

$
0
0

For my first WordPress plugin I chose to make it my self difficult because I want to use a new table in the WordPress database installation.

However if I install the plugin the database tables are not created for some sort of reason. I checked the query in phpMyAdmin and it runs fine in there so there aren't any errors in the query, but what am I doing wrong?

<?php
// database creation
function create_rozenactie(){

$sql1 = "CREATE TABLE rozenactie (
  order_id int(11) NOT NULL AUTO_INCREMENT,
  ontvanger varchar(225) NOT NULL,
  klas_ontvanger varchar(50) NOT NULL,
  boodschap varchar(250) NOT NULL,
  aantal int(11) NOT NULL,
  bedrag int(11) NOT NULL,
  afzender varchar(225) NOT NULL,
  klas_afzender varchar(225) NOT NULL,
  email varchar(250) NOT NULL,
  betaalmoment varchar(250) NOT NULL,
  betaald varchar(200) NOT NULL,
  anoniem varchar(20) NOT NULL,
  PRIMARY KEY  (order_id)
);";

require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta($sql1) or die("Instalatie tabel Rozenactie mislukt");

}

function create_algemeen(){

$sql2 = "CREATE TABLE algemeen(
  actief varchar(25) NOT NULL,
  prijs varchar(11) NOT NULL
);";

require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta($sql2) or die("Instalatie tabel Algemeen mislukt");
}

function insert_general_settings(){
global $wpdb;

$aanpassen = $wpdb->insert( algemeen, array('actief' => 'true', 'prijs' => '1') );
$aanpassen;
}
?>

Klikkit on "Admin Bar"

$
0
0

I have a plugin (S2Member) that allows different levels of subscribers for a customer's site.

I want to edit the Grey admin bar according to the user account type.

Example:

Admin account = bar is default
Subscriber/All other accounts = bar displays 'Welcome *account name* with the option to log out or view their profile (custom link)

How would I go about this?

format19 on "Nested Shortcode - WP-Invoice and WP Print this section half working"

$
0
0

Hi,
I am trying to use the Print This Section plugin with WP-Invoice and have been stuggling for days now trying to figure out where the problem is?

With Both WP-invoice installed and working and WP Print This section also installed and working. On my Invoice page i have used
[print_this]
[wp-invoice]
[/print_this]

This displays perfectly the WP-invoice shortcode is read and processed and displays inside the Print this section box.

The problem is when i click the "Print This" button the page that opens up actually displays the text [wp-invoice] and not the actual invoice ?

I have been all over the net and tried many things to do with nested shortcodes, from what i can tell I need a "do_shortcode($content)" somewhere but i cant figure out where?

A link to the sample invoice and problem:
http://www.yourtechally.com/client-login/invoice-online/?invoice_id=ef77a582808c0973b62d79f40059ce30

Any help would be greatly appreciated
Kind regards
Mark

pilar777 on "Website files lost!!! Help!!!"

$
0
0

Please help me. My website, kreativesoulsbypilar.com/eyespeak has vanished. I put up a placeholder. ALL my files...gone. please help!!!

groncali on "appointment booking plugin with a credit system"

$
0
0

Hi Matt,

you could use Bookeo online bookings (http://www.bookeo.com), where you can assign credits from the back end, that can be redeemed against online bookings.

We do have a wordpress plugin.

Feel free to visit our website or send us an email at help@bookeo.com if you have any question.

Giovanna Roncali
Bookeo online bookings

axymak on "How to check the Plugin us safe or not"

$
0
0

Hello Friends I'm using a Tech blog and It is working well.How to check the plugins that are safe or not. Before installing them ?

Smith on "Hack resolution"

$
0
0

I recently had four sites hacked simultaneously. Bluehost provided a backup restore which brought everything back. I made sure I had the latest version of WP, checked there were no updates to plugins, which I do daily, and changed my passwords using the cPanel generator. The following day the external sites were fine but the dashboards only contained a list on the left of hyperlinks that don't work.

I deleted the plugins through cPanel which has brought back two of the dashboards, but two remain messed up. I uploaded the wp-admin folder from a previous backup but this hasn't worked either.

I've scanned my machine which didn't throw up any bugs and I've checked the condition is the same in other browsers, which it is.

Any help/guidance would be appreciated.


creifel on "Quick Cash Advance Spam Link"

$
0
0

I have some spam that is showing up in select RSS Feed readers of my blog:

http://thesimpleyear.com

The spam/link is "Quick Cash Advance With Small Commissions" and seems to be showing up consistently after the first paragraph of the blog post on Google and Yahoo RSS Feed Readers. It does not appear on the site itself or the RSS feed view on the site itself. I had a similar problem several months ago with the Pay Day Loan spam and was able to find the malicious code in a couple different files. Haven't had any problems since but not having much luck this time around. This problem showed up one day after I was experimenting with different Instagram posting plugins, all of which I have since removed but the problem remains.

Can anyone point me to the specific files that might contain the malicious code?

I have already taken several steps to include re-loading WP 3.5.1 and most of my plugins.

Thanks in advance for your help
Chris

shihabmalayil on "How can i multiple the custom fields?"

$
0
0

Here i have the code, if i add one field what changes i have to do in this code?.
exp: add one textarea

<?php
/* Define the custom box */

add_action( 'add_meta_boxes', 'myplugin_add_custom_box' );

// backwards compatible (before WP 3.0)
// add_action( 'admin_init', 'myplugin_add_custom_box', 1 );

/* Do something with the data entered */
add_action( 'save_post', 'myplugin_save_postdata' );

/* Adds a box to the main column on the Post and Page edit screens */
function myplugin_add_custom_box() {
    $screens = array( 'post', 'page' );
    foreach ($screens as $screen) {
        add_meta_box(
            'myplugin_sectionid',
            __( 'My Post Section Title', 'myplugin_textdomain' ),
            'myplugin_inner_custom_box',
            $screen
        );
    }
}

/* Prints the box content */
function myplugin_inner_custom_box( $post ) {

  // Use nonce for verification
  wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_noncename' );

  // The actual fields for data entry
  // Use get_post_meta to retrieve an existing value from the database and use the value for the form
  $value = get_post_meta( $post->ID, '_my_meta_value_key', true );
  echo '<label for="myplugin_new_field">';
       _e("Description for this field", 'myplugin_textdomain' );
  echo '</label> ';
  echo '<input type="text" id="myplugin_new_field" name="myplugin_new_field" value="'.esc_attr($value).'" size="25" />';
}

/* When the post is saved, saves our custom data */
function myplugin_save_postdata( $post_id ) {

  // First we need to check if the current user is authorised to do this action.
  if ( 'page' == $_POST['post_type'] ) {
    if ( ! current_user_can( 'edit_page', $post_id ) )
        return;
  } else {
    if ( ! current_user_can( 'edit_post', $post_id ) )
        return;
  }

  // Secondly we need to check if the user intended to change this value.
  if ( ! isset( $_POST['myplugin_noncename'] ) || ! wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename( __FILE__ ) ) )
      return;

  // Thirdly we can save the value to the database

  //if saving in a custom table, get post_ID
  $post_ID = $_POST['post_ID'];
  //sanitize user input
  $mydata = sanitize_text_field( $_POST['myplugin_new_field'] );

  // Do something with $mydata
  // either using
  add_post_meta($post_ID, '_my_meta_value_key', $mydata, true) or
    update_post_meta($post_ID, '_my_meta_value_key', $mydata);
  // or a custom table (see Further Reading section below)
}
?>

-Thankyou-

hhins on "Plugin styling, overriding themes, finding a balance."

$
0
0

I'm writing a plugin to be used by a wide variety of unknown themes (like most) and struggling with how to balance styling the plugin enough to look nice, while allowing the underlying theme styles to come through so it blends somewhat.

Are there any style guidelines I haven't been able to track down?

I'll be very specific in my css for styling only the plugin elements but I'm afraid if I'm not specific enough or resetting the elements (ul, li, p, etc...) I'll have some unusual surprises down the road with themes with very unusual formatting.

Thanks for any suggestions

clickmac on "get_post_meta woocommerce billing_email"

$
0
0

anyone got any idea how to get_post_meta from saved value of woocommerce billing_email input?

just would like to get the data stored by the customer and display it?

kikimarie123 on "Share Content - External Links Generate Excerpt Thumbnail"

$
0
0

Is there a plugin out there that allows you to insert a link from any site and then it generates a thumbnail and excerpt. Just how when you insert a link on Facebook or LinkedIn, the thumbnail from the source and an excerpt of the post/article generates.

I'm developing a community-based (private) website, via Buddypress, and I want users to be able to share links to interesting articles but I don't want it to be just a link. It would look weird and tacky. I was going to make an option to upload a PDF but I'd much rather have the Facebook/LinkedIn style of sharing external links.

Anyone have any ideas? I've searched high and low...

TimG1 on "How do I pass arguments using add_action() to an existing action?"

$
0
0

Hello everyone,

Instead of doing something like this...

function remove_taxonomy_boxes() {
            remove_meta_box('categorydiv', 'post', 'side');
    }
    add_action( 'admin_menu' , 'remove_taxonomy_boxes' );

Is it possible to do something more like this?

function remove_taxonomy_boxes($box_id, $page, $context) {
            remove_meta_box($box_id, $page, $context);
    }
    add_action( 'admin_menu' , 'remove_taxonomy_boxes', 10, 3 );
    do_action( 'admin_menu', 'categorydiv', 'post', 'side');

I understand the second code example is incorrect, but the idea is what I'm trying to do. I want to try and make my code a little more reusable instead of having to write the first code example's custom function with hard coded values for every case I want. Maybe there is an entirely different approach?

I found this thread, it's closed though and not quite what I'm looking for.

Many thanks!
-Tim

ti2m on "Trigger plugin delete without proper file permissions"

$
0
0

My plugin comes with custom tables which I want to delete when the plugin gets deleted, not when it just gets deactivated. I though I could use the deactivation and uninstall hook for this. Unfortunately the uninstall hook does not get triggered when wordpress can't delete the according plugin files.

For me, deleting tables + settings and files are two different things. For a user who has access to the files, but no FTP access, he is able to delete the files manually, but he will be left with the tables. Am I missing something? Searched the codex and looked it up in "wordpress professional", but right now it looks like the uninstall hook gets only triggered after file delete permissions are checked???

Thanks for a hint


Luismin on "Order posts by custom post type in dropdown field"

$
0
0

Hi commnunity!

In my WordPress backend I have some custom posts and, in one of them, I want to display in a dropdown field some posts related with but ordered by post type. I want to display something like this.

<select multiple="multiple" style="height:200px; width:300px"> <optgroup label="Productos"> <option>Producto 1</option> <option>Producto 2</option> <option>Producto 3</option> <option>Producto 4</option> <option>Producto 5</option> <option>Producto 6</option> </optgroup> <optgroup label="Paso 1"> <option>Subpagina 1</option> <option>Subpagina 2</option> <option>Subpagina 3</option> </optgroup> </optgroup> <optgroup label="Paso 2"> <option>Subpagina 1</option> <option>Subpagina 2</option> <option>Subpagina 3</option> </optgroup> </optgroup> <optgroup label="Paso 3"> <option>Subpagina 1</option> <option>Subpagina 2</option> <option>Subpagina 3</option> </optgroup> </select>

Here is the code that displays all of posts that I want but without order. I figure out that I have to use the id of the custom post type but I do not how to, any idea?

Note: I`ll like to save more than one post at the same time.

// Add the Meta Box  

function add_custom_meta_box_related() {
    add_meta_box(
        'custom_meta_box_related', // $id
        'Related Information', // $title
        'show_custom_meta_box_related', // $callback
        'related', // $page
        'normal', // $context
        'high'); // $priority
}
add_action('add_meta_boxes', 'add_custom_meta_box_related');

    // Field Array
    $prefix_related = 'custom_';
    $custom_meta_fields_related = array(  

		array(
			'label' => 'Related Items',
			'desc' => 'Select a related item(s)',
			'id'    =>  $prefix_materiales.'post_id',
			'type' => 'post_list',
			'post_type' => array('products','paso1','paso2','paso3','paso4','compra'),
)
    );  

	// The Callback
function show_custom_meta_box_related() {
global $custom_meta_fields_related, $post;
// Use nonce for verification
echo '<input type="hidden" name="custom_meta_box_nonce" value="'.wp_create_nonce(basename(__FILE__)).'" />';  

    // Begin the field table and loop
    echo '<table class="form-table">';
    foreach ($custom_meta_fields_related as $field_related) {
        // get value of this field if it exists for this post
        $meta_related = get_post_meta($post->ID, $field_related['id'], true);
        // begin a table row with
        echo '<tr>
                <th><label for="'.$field_related['id'].'">'.$field_related['label'].'</label></th>
                <td>';
                switch($field_related['type']) {
                    // case items will go here 

					// post_list
					case 'post_list':
					$items = get_posts( array (
						'post_type' => $field_related['post_type'],
						'posts_per_page' => -1
					));
					echo '<select multiple name="'.$field_related['id'].'" id="'.$field_related['id'].'">
					<option value="">Select One or more</option>'; // Select One
					foreach($items as $item) {
						echo '<option value="'.$item->ID.'"',$meta_related == $item->ID ? ' selected="selected"' : '','> '.$item->post_title.'</option>';
					} // end foreach
					echo '</select><br /><span class="description">'.$field_related['desc'].'</span>';
					break;
                } //end switch
        echo '</td></tr>';
    } // end foreach
    echo '</table>'; // end table
}

// Save the Data
function save_custom_meta_related($post_id) {
    global $custom_meta_fields_related;  

    // verify nonce
    if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__)))
        return $post_id;
    // check autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
        return $post_id;
    // check permissions
    if ('page' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id))
            return $post_id;
        } elseif (!current_user_can('edit_post', $post_id)) {
            return $post_id;
    }  

    // loop through fields and save the data
    foreach ($custom_meta_fields_related as $field_related) {
        $old = get_post_meta($post_id, $field_related['id'], true);
        $new = $_POST[$field_related['id']];
        if ($new && $new != $old) {
            update_post_meta($post_id, $field_related['id'], $new);
        } elseif ('' == $new && $old) {
            delete_post_meta($post_id, $field_related['id'], $old);
        }
    } // end foreach
}
add_action('save_post', 'save_custom_meta_related');

Thanks in advance

CheckMater on "$wdpv returning nothing when using it via AJAX plugin."

$
0
0

Good day, I have a problem with my plugin because $wdpb returns an error when trying to do any query, my code is as follows:

function search_engine_callback() {
	global $wpdb;
	$keyword = addslashes($_POST['keyword']);
	//Get all related posts from the WP db...
	$wpdb->show_errors();
	$res = $wpdb->get_results("SELECT id, post_title FROM wp_posts  WHERE post_title = '$keyword'", 'ARRAY_A');

And it shows me this error:

Wordpress Database Error: [] and the previous query.

All works fine in the AJAX function but the query doesn't return anything (No matter which query you add) it always return an empty [] as error.

Any suggestion?

Thanks in advance!

ajmancilla on "Displaying custom post type field, but displaying the repeating ones only once."

$
0
0

Hi everyone,

Hope someone can help me here.

I am using WP Types plugin to create custom post types. so the thing is i have a post type with doctors and their city and state as custom fields.

so from another post type page i am trying to populate all the cities within a state.

So far i am able to pull the cities corresponding to that state but since i have several doctors in a city the cities repeat themselves.

How can i prevent this to happen so it only displays the city one time?

this is my code

<?php 

$states_var = $_GET['states'];

$loop = new WP_Query( array( 'post_type' => 'doctors', 'posts_per_page' => 10 ) );

while ( $loop->have_posts() ) { 

		$loop->the_post();

		$cities = get_post_meta($post->ID,'wpcf-city');
		$states = get_post_meta($post->ID,'wpcf-state');

		foreach($states as $state){

				if($state == $states_var){

						foreach ($cities as $city) {

									echo "<a href=\"?cities=main&city=".$city."\">".$city."</a><br />";

						}
				}
		}

}
?>

[No bumping, thank you.]

AntonioFajdiga on "How to show only posts from one category"

$
0
0

I want to show only posts from category Publications on my right side, using Archive widget and to have on more widget like Recent post, where i can show all other posts.

Reakon on "Reply to comment on single comment page"

$
0
0

Dear,

At this moment I am working on a comment system for one of my clients but I am running into a problem.

The comment system has some additions to it, since the comments are 'concepts, ideas & inspirations' - kind of crowdsourcing community.

Anyways, I now have: the comment excerpt a image and the title on the normal page, with a link to the bottom 'See more' (Zie meer in dutch).
When clicking on this link you're brought to a another page where the whole comment can be seen (images, story, etc).

I do this as following:

<a href="single-comment/?id=<?php echo comment_ID(); ?>&auteur=<?php comment_author(); ?>&pageid=<?php echo get_the_ID(); ?>">See more</a>

Then I pull the comment ID & the page ID from the link (the author is there for SEO reasons).

if(isset($_GET["id"]) && isset($_GET["auteur"]) && isset($_GET["pageid"]))
    {
     $commentid = $_GET["id"];
     $auteur = $_GET["auteur"];
     $page_id = $_GET["pageid"];
    }

$comment = get_comment( $commentid );

But now my client had the question; can people reply to a 'idea, concept or inspiration added by another user' - this 'ideas, concepts or inspirations' are technically seen comments.

So I tried to add a 'reply to' link:

$commentreply = get_comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth'])), $comment->comment_ID);

but when I 'var_dump' this... it says: "NULL".

Anyone an idea how to make this kind of comment system?

Viewing all 8245 articles
Browse latest View live




Latest Images