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

amandathewebdev on "JavaScript/jQuery toggle not working"

0
0

Hi all,

I'm hoping someone can give me advice on this. I have a JavaScript function that used to work, and now it doesn't. On this page: http://www.nfe-lifts.com/inventory/ when you check "Advanced Search", a hidden div is supposed to show.

Here is the function:

$('#advanced-options').on('change', function() {

   $.cookie('advanced-search', $(this).is(':checked')?'1':'0');

   if($(this).is(':checked')) {
       $('#advanced-div').show();
   } else {

       $('#advanced-div').hide('slow');

   }

   if($.cookie('advanced-search') == '1') {

        $('#advanced-options').prop('checked', true).trigger('change');

   }
 });

I'm on WP Engine and recently learned that they block certain cookies. They assured me that's not what's happening here. I'm not sure why this isn't working. Any help would be appreciated.


poopymonster on "Adding a "Upload to imgur" button under every new gallery thumbnail"

0
0

I have a working drag and drop system that uploads an image to Imgur from the users hard drive, the code is shown below.

How can I modify this code so instead of using an image from a users HD, each thumbnail from old and new galleries get an "Upload to Imgur" button which sends the full size image to Imgur where the user in turn can use their image editing services.

Or iw there a WP plugin that already does this?

`<div>DROP!<button onclick="document.querySelector('input').click()">Or click</button></div>
<input style="visibility: collapse; width: 0px;" type="file" onchange="upload(this.files[0])">

<p>Uploading...</p>
It's online!!!

<script>

/* Drag'n drop stuff */
window.ondragover = function(e) {e.preventDefault()}
window.ondrop = function(e) {e.preventDefault(); upload(e.dataTransfer.files[0]); }
function upload(file) {

if (!file || !file.type.match(/image.*/)) return;
document.body.className = "uploading";

var fd = new FormData();
fd.append("image", file);
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://api.imgur.com/3/image.json");
xhr.onload = function() {
document.querySelector("#link").href = JSON.parse(xhr.responseText).data.link;
document.body.className = "uploaded";
}

xhr.setRequestHeader('Authorization', 'Client-ID');

xhr.send(fd);
}
</script>'

nerdburglars on "Load wp-blog-header.php without starting the loop."

0
0

I need to be able to load up wordpress and load up the theme, but i dont want to perform any queries against the WP database for posts. I have a custom php file that gets a post from a non WP database. I have setup the htaccess file to correctly route this. The top of the script loads wordpress.

require_once('../../../wp-blog-header.php');

From here i get the global $post object and populate it with the custom data that i want to display on the page. I also need to alter the response http code since calling wp-blog-header.php generates a 404 error since no post was found. I need to cut this part out, but still load up wordpress.

After populating $post i call the theme to render the post using the wordpress theme.

include get_template_directory()."/page.php";

This is working fine in web browsers. I have fixed all issues and it renders great, but search engines and bots have trouble with it. For example, if the url of the page is mysite.com/something, wordpress checks for a post with a slug that contains this value. 90% of the time it doesnt find a post and generates a 404, which i am able to handle. 10% of the time it finds a similar slug. eg. "somethingelse" and performs a 301 redirect which is causing a lot of trouble.

How can i load up wordpress and be able to call the theme without it querying the wordpress DB for a post?

sharkonda on "Imagemapster Jquery Plugin"

0
0

Hi, I'm using Imagemapster for adding a hover effect to my header image. I successfully load the imagemapster.js, my script (also .js in theme folder), but nothing seems to happen. I've already digged around on Google for answers, and I've found nothing that works.
Here's the code:
jQuery(document).ready(function($) {
$('#navigacija'}.mapster({
singleSelect : true,
clickNavigate : true,
mapKey: 'color',
fill : true,
altImage : 'wp-includes/images/files/posaoodkuce-nav-image-hover.gif',
fillOpacity : 1,
});
});`

here's the site: http://posaoodkuce.com/

kelecz on "PHP array problem in WP plugin"

0
0

Guys,
need help.

Those are errors:

https://mega.nz/#!iBA2hYDB!WayC-AWYO4PafNZ9f6kyoeaUicaYn-mWtJtMVillfDo

and this is code :

$dropdown_cities = array_reduce( $cities, 'array_merge', array() );
					sort( $dropdown_cities ) ;
				}

				foreach ( $dropdown_cities as $city_name ) {

What should I correct here?

THX!

draftpick on "[Plugin: My Wish List] setting the maximum value"

0
0

Hello,

I've modified My Wish List plugin. Users have a possibility to choose certain amount of products/gifts (for example 4 of 10). I would like to have a script to calculate the maximum value for the amount field. However I don't know how to get the values from 'total' and 'reserved' variables for the calculation operation.

if( $meta['reserved'] < $meta['total'] ) {
	if( $wishlist_show_form == "show" ) {
		$output .= '<form method="post" action="" class="wishlist-form">';
		$output .= '<table>';
		$output .= '<tr><td><span class="wishlist-form-label">Name:</span></td><td><input name="wishdonorname" type="text" class="wishlist-form-input" /></td></tr>';
		$output .= '<tr><td><span class="wishlist-form-label">E-mail:</span></td><td><input name="wishdonoremail" type="text" class="wishlist-form-input" /></td></tr>';
		$output .= '<tr><td><span class="wishlist-form-label">Amount:</span></td>
<td>
<input name="reserved" id="reserved" type="number" min="1" class="wishlist-form-input" />
<script type="text/javascript">
var input = document.getElementById("reserved");
input.setAttribute("max","10");
</script>
</td>
</tr>';

coumineol on "Require authentication for plugin activation"

0
0

Hi, this may be a trivial thing but I searched and wasn't able to find a thing about it. When someone installs my plugin and tries to activate, I want to ask for username and password, and block the activation if it's wrong. I messed with register_activation_hook a little bit, but wasn't able to come with anything. Is it possible, and if so, how? Thanks.

suncoding on "Lock attacks by adding IP deny to htaccess when specific 404 page request"

0
0

Hi,

I have some intrusion atempts on my blog that ends by 404 http status.

So i built a script that cacth the requested url and then it checks if there is a chain corresponding to "/wp-includes/" or "/wp-content/" in it.

Finally it adds a "deny the client IP line" in htaccess when this happend to be true.

All is good when typing an url in browser in this case.

But I need this script to be on a lower level, before template loadings, even before the server sends the HTTP status header 404 code to the client.

Is there way to do that whitout having wordpress updates erasing the hack. Maybe with templates functions ?

I've seen these functions that looks intersting :
/wp-includes/class-wp-http-response.php/

I'm not a strong developer and english is not my first language,
Thanks for your help, and sorry if i wrote mis-spelings,


ten-em on "How to add logged in user info without php"

0
0

Hi,

I am trying to dynamically pull the logged in user's email address into a form before it is submitted. Here is the code:

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

<form method="post" ><input id="email" name="user_email" type="hidden" value="LOGGED IN USER EMAIL HERE" />
<input type="submit" value="Register for webinar" /></form>

Any idea how I do this without php?

Thanks

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 -.-

ZED Solutions on "How update triggers are working?"

0
0

Hi, I want to auto run our backup scripts before plugin/core or any update happens, either auto or manually.
What triggers when WP is updating?
Thanks

Vladimir Mrkela on "Preview Changes - save_post hook not firing every time"

0
0

Hello everyone,

I have issue I've been struggling few days already and couldn't find a problem so I hope someone has an idea.

We have our own page builder for all our buyers so they can build pages easily. Problem I encounter is that when user adds new element to page builder grid and try to preview the results, hook "save_post" doesn't fire. Actually it fires every second time.

I search all over the web and my conclusion is:
- when user clicks on Preview Changes, WordPress store post Revision
- Hook "save_post" will fire only when there are changes in WordPress editor. Because user is adding content through page builder and nothing actually changes in WP Editor those changes are not detected.

I tried changing tinyMCE "isDirty" parameter on two different ways when user adds content to page builder:

tinyMCE.activeEditor.setDirty(true);
tinyMCE.activeEditor.isNotDirty = false;

Neither is working.

I assumed that changing this parameter when user adds new element to page builder will force firing save_post hook every time but unfortunately it doesn't.

I also tried to track "save_post" hook in WordPress core files to find how and when it fires but this ended without results.

I think that page builder is not important at all in this case as I actually need (probably) to simulate change in WP Editor to force save_hook to fire.

I am out of ideas so I would appreciate if someone has idea how to resolve this.

Thank you,
Vladimir

mmdwc on "front end publishing (wp_insert_post) on home page, archive page & search page"

0
0

I'm using a custom front end publishing form on my website using wp_insert_post, based on this article.

It works perfectly when I put this code inside a page, but when on the front-end page (homepage), archive page and search page, it doesn't work, and when I submit the form, I'm redirected to an archive.php page, the archive page from the post_category I've chosen in my form.

I think there might be a conflict with my submit button, I really don't know what's happening.

anyone can help me with this ?

here is my code

<?php
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&  $_POST['action'] == "new_post") {

  // Do some minor form validation to make sure there is content
  if (isset ($_POST['title'])) {
    $title =  $_POST['title'];
  } else {
    echo 'veuillez entrer un titre';
  }
  if (isset ($_POST['description'])) {
    $description = $_POST['description'];
  } else {
    echo 'veuillez entrer du texte';
  }

  $genre = $_POST['genre'];
  $tranche_age = $_POST['tranche_age'];

  // ADD THE FORM INPUT TO $new_post ARRAY
  $new_post = array(
  'post_title'  =>  $title,
  'post_content'  =>  $description,
  'post_category' =>  array($_POST['cat']), // Usable for custom taxonomies too
  //'tax_input' => array( 'regions' => '14' ),
  'post_status' =>  'publish',           // Choose: publish, preview, future, draft, etc.
  'post_type' =>  'post',  //'post',page' or use a custom post type if you want to
  //'genre'  =>  $genre,
  //'tranche_age'  =>  $tranche_age,
  );

  //SAVE THE POST
  $pid = wp_insert_post($new_post);

  wp_set_post_terms($pid,array($_POST['regions']),'regions',true);
  wp_set_post_terms($pid,array($_POST['sexes']),'sexes',true);
  wp_set_post_terms($pid,array($_POST['ages']),'ages',true);

  //REDIRECT TO THE NEW POST ON SAVE
  $link = site_url();
  wp_redirect( $link );

  //ADD OUR CUSTOM FIELDS
  //add_post_meta($pid, 'genre', $genre, true);
  //add_post_meta($pid, 'tranche_age', $tranche_age, true);

} // END THE IF STATEMENT THAT STARTED THE WHOLE FORM

//POST THE POST YO
do_action('wp_insert_post', 'wp_insert_post');

?>

    <div id="container">
      <div id="content" role="main">

    <!-- FRONT END PUBLISHING -->

    <div class="wpcf7">
    <form id="new_post" name="new_post" method="post" action="" class="wpcf7-form" enctype="multipart/form-data">
      <!-- post name -->
      <fieldset name="name">
        <label for="title">Titre:</label>
        <input type="text" id="title" value="" tabindex="5" name="title" />
      </fieldset>

      <!-- post Category -->
      <fieldset class="category">
        <label for="cat">Catégorie :</label>
        <?php wp_dropdown_categories( 'tab_index=10&taxonomy=category&hide_empty=0&show_option_all=Choisissez une catégorie' ); ?>
      </fieldset>

      <!-- post regions -->
      <fieldset class="regions">
        <label for="regions">Région :</label>
        <?php wp_dropdown_categories( 'name=regions&tab_index=10&taxonomy=regions&hide_empty=0&show_option_all=Choisissez une catégorie' ); ?>
      </fieldset>

      <!-- post Content -->
      <fieldset class="content">
        <label for="description">Question :</label>
        <textarea id="description" tabindex="14" name="description" cols="80" rows="10"></textarea>
      </fieldset>

      <!-- Genre -->
      <input type="hidden" id="sexes" name="sexes" value="26" />

      <!-- Tranche d'âge -->
        <?php $date_of_birth = um_user('birth_date'); $age =  CalculateAge($date_of_birth); ?>

        <?php if ($age >= 18 && $age <= 25) :?>

        <input type="hidden" value="28" id="ages" name="ages" />

        <?php endif; ?>

        <?php if ($age >= 26 && $age <= 35) :?>

        <input type="hidden" value="29" id="ages" name="ages" />

        <?php endif; ?>

        <?php if ($age >= 36 && $age <= 45) :?>

        <input type="hidden" value="30" id="ages" name="ages" />

        <?php endif; ?>

        <?php if ($age >= 46) :?>

        <input type="hidden" value="31" id="ages" name="ages" />

        <?php endif; ?>

      <fieldset class="submit">
        <input type="submit" value="Envoyer" tabindex="40" id="submit" name="submit" />
      </fieldset>

      <input type="hidden" name="action" value="new_post" />
      <?php wp_nonce_field( 'new-post' ); ?>
    </form>
</div>

</div>
</div>

tjoepke on "Always using gallery instead of single media"

0
0

Hello,
Most of our users using the wrong setting for there new post. Their messages contains different pictures (20).

I wonder if it is possible that we can changes 'AD MEDIA' to the option 'AD GALLERY'?

Thanks
JP

jonwatson87 on "WP_Query on tag.php"

0
0

I'm probably being dense, but I can't seem to figure out what the issue here is.

The site I'm developing uses a custom loop, with a query that excludes any posts ticked as archived.

The reason I want to edit the tag.php template is to output custom meta to the front end, and tweak the appearance of all posts on the archive pages.

It works perfectly for the majority of the site, but on tag.php it causes to tag cloud to break, making any and every tag clicked bring up the full post list.

When I remove the query the tag cloud works fine, but archived posts are still displayed and aren't laid out the way they need to be.

The query code I'm using is:

// The Queries
     $args = array(
	'post_type' => array('post', 'report', 'analysis', 'guest-blog'),
	'order'     => 'DESC',
	'meta_query'     => array(
		array(
		'key'     => 'epi_pubarchive',
		'value'   => 1,
		'compare' => '!=',
		)
	)
     );

     $the_query = new WP_Query( $args );

The meta key, epi_pubarchive, is a checkbox created using Meta Box, essentially checking if the box is ticked or not.

I've tried removing the meta_query and trying it with the basic post_type and order args, but that won't work either.

Anyone know what the issue with tags and queries is?

Is there a better way to achieve the desired result?


George Sexton on "The JQuery UI CSS Mess"

0
0

I'm running into kind of a consistent, recurring problem with my plugin and other plugins including JQuery UI.

My plugin displays dialogs, so I enqueue the appropriate javascript and wp-dialog CSS files.

However other plugins are including their own copy of JQuery-UI.css which causes the dialog to display incorrectly. You can see and example here:

http://wickfordcatholic.com/anniversaries/

click on one of the anniversary names. Here's another thread where I worked with another plugin vendor:


https://wordpress.org/support/topic/breaks-dialogs-includes-jquery-ui?replies=3

I understand why people are doing this. I tried to use the JQuery UI Datepicker, and was stymied because WP doesn't include the required CSS to make it work. That was super-frustrating because WP explictly names out the jquery-ui-datepicker as a script to be loaded.

I tried loading my own copy of JQuery UI.css from a CDN and I ran into the same problem.

I understand the issue with including a JQuery-UI theme because it might not match the WP theme at all, making people really unhappy.

Is this kind of problem solvable? I'm more of a back-end developer. Could a system be created to dynamically generate a complete JQuery-UI css file using hints provided by the theme? That way a themed, functionally complete JQuery UI CSS file could be delivered?

nirvvana on "How to remove or disable update button in publish section"

0
0

Hi everyone,

How can I remove or disable update button in publish section for specific user like (Editor), I just want the user be able to click on preview not Update.

anyone knows any trick or any plugins or anything that could help me in this way?

I really appreciate your time,

Kind regards

Giulio Daprela on "Need to add custom field to edit category page"

0
0

I need to add a custom field to the edit category page, and cannot find what hooks should I use for doing that.
I need to add a simple checkbox and save the user choice into the options page.

Any suggestions is welcome

Cuti on "Query works in phpmyadmin but not with $wpdb"

0
0

Hello !

I am trying to retrieve all user meta (in columns) for each users (in rows).

I build (not without pain) this query that is working in phpmyadmin :

SET group_concat_max_len=16384;
SET @sql = NULL;
SELECT
  GROUP_CONCAT( DISTINCT
	CONCAT(
	  'MAX( IF ( M.meta_key = ''',
	  meta_key,
	  ''', M.meta_value, NULL)) AS `',
	  meta_key, '`'
	)
  ) INTO @sql
FROM wp_usermeta;

SET @sql =
CONCAT( ' SELECT *, ', @sql,
' FROM wp_users as U, wp_usermeta as M
WHERE U.id = M.user_id
GROUP BY U.id ' );

PREPARE stmt FROM @sql;
EXECUTE stmt;

But when I execute it with $wpdb->get_results, it returns an empty array.

Anyone can help ?

bmontgomery on "How to sort the results of custom WP_Query by category name"

0
0

Hello,

I wrote a plugin that uses WP_Query to display some posts, depending of the users choices. The query is made on taxonomies.
It's working pretty well, but the only thing I'm not able to achieve is the order of the results.
I'd like to sort the results by catagory names, but it's not working...
In the args, here's what I wrote:

'orderby' => 'category',
'order' => 'asc',

I don't understand what's wrong. Could anybody help me?
Thanks

Viewing all 8245 articles
Browse latest View live




Latest Images