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

Riccardo on "Force download not working as expected"

$
0
0

On PHP I usually I use these lines of code to force a download:

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream', true, 200);
header('Content-Disposition: attachment; filename="MY_FILENAME"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
ob_clean();
ob_flush();
flush();
readfile('MY_FILE_PATH');
exit();

Now I tried to include the WordPress enviroment to it simply adding this on top of it:

require_once(dirname(__FILE__) . '/wp-load.php');

But now instead of instantly opening the browser download file dialog, the script runs for minutes (this lasts more for bigger files, it looks like the server is downloading the file) then only after this the browser shows the download file dialog where the user could clicks OK and starts the real download.

If I comment out the WordPress include it works as expected.

I have to use it for remote files, but it looks the same also on local files.

I tried various combinations of output buffering cleaning, flushing and restarting too.

Any hint on what feature of WordPress could cause this?


steven-stallone on "Embedding Video above post bar and side bar"

$
0
0

I have been trying for a while now to figure out how I can get video from YouTube to embed themselves above the post bar and side bar. Let me show you what I mean:

http://www.cinema5d.com/?p=23178

Now at first I was looking to see if there were any plugins that could do this and I couldn't find any. Then I was looking to see if I had to create some code to stick at the top of the loop php file so a simple video embedding plugin would automatically put it into that slot.

I'm wondering how exactly is it possible that the site above did this? When I try and insert an image at the top of the loop it won't span the full width and stops at the sidebar. Is there a piece of code I can put into the header or at the top of the loop that will only display a video from a post that is assigned to a post? I would like it to work with a plugin.

giampietro on "Save data to Mysql from page template form"

$
0
0

Hello to all,
I'm trying to save the form data from one page to wordpress Mysql database in ajax.

The script works but the data is not washed out, if anyone can help me thanks!
save_data.php content:

<script type="text/javascript">
jQuery(document).ready(function(){
	jQuery("#confirm").click(function(){
		var name = jQuery("#mc-name").val();
	    var name = jQuery("#mc-email").val();
	    var name = jQuery("#mc-phone").val();
	    var name = jQuery("#result_ricavi_vendita").val();
	    var name = jQuery("#result_materie_prime").val();
	    var name = jQuery("#result_utilities").val();
	    var name = jQuery("#result_consumabili").val();
	    var name = jQuery("#result_costi_variabili").val();
	    var name = jQuery("#result_personale").val();
	    var name = jQuery("#result_affitto").val();
	    var name = jQuery("#result_ammortamento").val();
	    var name = jQuery("#esult_manutenzione").val();
	    var name = jQuery("#result_varie").val();
	    var name = jQuery("#result_costi_fissi").val();
	    var name = jQuery("#result_tot_costi").val();
	    var name = jQuery("#result_ebit").val();
	    var name = jQuery("#result_ebit_perc").val();
	    var name = jQuery("#last_message").val();
		jQuery.ajax({
		type: 'POST',
		url: ajaxurl,
		data: {"action": "esmach_app", "mc-name":name},
		success: function(data){
		alert('Prospetto salvato con successo!');
		}
		});
	});
});
</script>

jQuery script

<?php
	require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
	function esmach_app(){

$name = $_POST['mc-name'];
			$email = $_POST['mc-email'];
			$phone = $_POST['mc-phone'];
			$result_ricavi_vendita = $_POST['result_ricavi_vendita'];
			$result_materie_prime = $_POST['result_materie_prime'];
			$result_utilities = $_POST['result_utilities'];
			$result_consumabili = $_POST['result_consumabili'];
			$result_costi_variabili = $_POST['result_costi_variabili'];
			$result_personale = $_POST['result_personale'];
			$result_affitto = $_POST['result_affitto'];
			$result_ammortamento = $_POST['result_ammortamento'];
			$result_manutenzione = $_POST['result_manutenzione'];
			$result_varie = $_POST['result_varie'];
			$result_costi_fissi = $_POST['result_costi_fissi'];
			$result_tot_costi = $_POST['result_tot_costi'];
			$result_ebit = $_POST['result_ebit'];
			$result_ebit_perc = $_POST['result_ebit_perc'];
			$last_message = $_POST['last_message'];

global $wpdb;
$wpdb->insert(
	'wp_ajax_demo',
 array( 'mc-name' => $name, 'mc-email' => $email, 'mc-phone' => $phone, 'result_ricavi_vendita' => $result_ricavi_vendita, 'result_materie_prime' => $result_materie_prime, 'result_utilities' => $result_utilities, 'result_consumabili' => $result_consumabili, 'result_costi_variabili' => $result_costi_variabili, 'result_personale' => $result_personale, 'result_affitto' => $result_affitto, 'result_ammortamento' => $result_ammortamento, 'result_manutenzione' => $result_manutenzione, 'result_varie' => $result_varie, 'result_costi_fissi' => $result_costi_fissi, 'result_tot_costi' => $result_tot_costi, 'result_ebit' => $result_ebit, 'result_ebit_perc' => $result_ebit_perc, 'last_message' => $last_message, ),
 array( 

		'%s'

	) ); 

die();

return true;

}
?>

[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

I have already created the table manually wp_ajax_demo but the data is not saved.
thank you

Diego Quintana on "get_calendar future posts and choose category"

$
0
0

Hey everyone. I've been looking all over the place for this but just can't get it to work.

I need to get the get_calendar function to use both published AND future posts, and need to be able to choose which category of posts (or taxonomy) to use.

I've tried pretty much every plugin there is out there but they all just have too many functions or just don't work. I just need to hack get_calendar.

I assumed this would be done by duplicating the get_calendar function and passing the post_status array and adding an extra field to the function, but I've seen it would involve using wpdb->posts and what not and from there on out I'm left hanging.

Anyone knows how to do it or has seen a similar solution?

Thank you so much in advance!

helika on "Custom image size in new media uploader"

$
0
0

I am developing a relatively simple Wordpress plugin for a client. It is used to upload/select images which are then saved (as image path) in the option variables and used as full-background images for the website's different categories/pages/etc..

Since images are of "wallpapery nature" (i.e. big) I added a custom image size with a maximum width of 1920 pixels (height is set to "auto", i.e. no image cropping). And that part also works, upon upload, images are being resized to my custom 1920 px width.

Now, the thing is, for uploading/choosing the background image I'm using the new media uploader and it works except that the chosen image (path) is always for the original uploaded image, for example "my-background-image.jpg".

My question is: is there a way to enable users (or make the uploader do it automatically) to select the 1920 px sized version of the original image, for example "my-background-image-1920x1080.jpg"?

Thanks!

Feyisayo1 on "Where to edit in wp-login.php"

$
0
0

Hey guys, I built a website for a client and he has been bugging me on changing the "Repeat Password" text on the WordPress register form to something else, I have searched the entire wp-login.php file for hours now looking for the string "Repeat Password" without any luck . I was only able to find the "Password" label but not "Repeat Password" , please help me!

JeremyCh on "Tried to write a very basic plugin, help please plugin gurus !"

$
0
0

I tried to write a very basic plugin, taking information from the net. For the moment I am yet to add any proper code, and first I was checking if things were working. I found its not working, both of the below functions failed to load.

Both eo.php (the file with the following codes) and eos.css are in the same folder : wp-content/plugins/eo/

if( !function_exists('eo')){
    	function eo($text) {
    		$text = str_replace('Test', 'Best', $text);
    		return $text;
    	}
    	add_filter('the_content', 'eo');
    }

    if( !function_exists('eos')){
    	function eos( ){
    		wp_register_style( 'eo', plugins_url('eo/eo.css', __DIR__) );
    		wp_enqueue_style( 'eo' );
    	}
    	add_action( 'wp_enqueue_scripts', 'eos' );
    }

And then question, can I load a js file along with like this ?

if( !function_exists('eos')){
        	function eos( ){
        		wp_register_style( 'eo', plugins_url('eo/eo.css', __DIR__) );
    			wp_register_script( 'eojs', plugins_url('eo/eo.js', __DIR__) );
        		wp_enqueue_script( 'eo' );
    			wp_enqueue_script( 'eojs' );
        	}
        	add_action( 'wp_enqueue_scripts', 'eos' );
    }

Any help will be welcomed
Thanks a lot :)

charles_i on "How do you switch the down state of image based navigation based on media size?"

$
0
0

I am converting a site into WordPress. The site has image based navigation with rollover buttons and a down state when you are on the current page. The site is here http://thecellarsisters.ca/sisterswp/ - click on "About" and the cork down state stays on. I have this working perfectly, as you can see. CSS is used to change the hover state and CSS in the page template puts the nav button into the down state.

Now my problem is with responsiveness. When you resize the browser window I have replaced the nav images with smaller images once you are below 680px. But how do I then switch the down state button from the larger one to the smaller one? I'm thinking that this requires two javascripts. Your Craig Buckler of OptimalWorks.net script for screen width detection will give you the browser width once you move it, but when you first load the page it says "unknown" because it hasn't been moved yet. I would almost need to combine his script with an instant detection. Then I need to create an if statement in javascript that will implement the correct CSS - if that's even possible.

I was trying to do something like this but it doesn't work because I need to convert the $sizer code to a string.

<?php
$sizer = '<div id="menu">unknown</div>'.toString();

$test =  'less than 680 pixels';
if ($sizer == $test){
  <style>
    li#menu-item-28 a {
     background-image:url('http://thecellarsisters.ca//sisterswp/wp-content/themes/sisters/images/nav_about_on15.jpg');
</style>
}  else {
   li#menu-item-28 a {
   background-image:url('http://thecellarsisters.ca//sisterswp/wp-content/themes/sisters/images/nav_about_on.jpg');
  }
 }
}
?>

Even if that worked it doesn't cover the current browser width when the page is loaded.

This seems incredibly complex for what must be something that has been commonly implemented. I can find plugins for nav images but nothing that will then replace each page's image with the smaller down state image for mobiles.

Any ideas about how to do this?

Thanks
Charles


varun p on "Adding custom option to menu items in wordpress"

$
0
0

I would like to add a dropdown field to the existing menu items in menu editor in wordpress. For example,When I add a page/post to the menu,I get a collapsible panel,in which there are navigation field & title attribute.Here I want to add one more field which will be a dropdown. Can someone help me with some source to get this done.

clementaurny on "Unable to activate Jquery roundabout for Post"

$
0
0

When activate the plugin Jquery for roundabout, i have an unexpected error syntax :

Parse error: syntax error, unexpected 'elseif' (T_ELSEIF) in /blog/wp-content/plugins/jquery-roundabout-for-posts/inc/roundabout_options.php on line 149
Try to change the conditionnals but get nothing work on activate..

gulliver on "Custom message on admin page after disabling visual editor."

$
0
0

I use a mod to disable the visual editor for all users.

add_filter ( 'user_can_richedit' , create_function ( '$a' , 'return false;' ) , 50 );
add_action( 'admin_print_styles-profile.php', 'hide_rich_edit_option' );
add_action( 'admin_print_styles-user-edit.php', 'hide_rich_edit_option' );
function hide_rich_edit_option() {
?>
<style type="text/css">
label[for=rich_editing] input { display: none; }
label[for=rich_editing]:before { content: 'The option to enable the visual editor has been removed (in functions.php). (Formerly: ' }
label[for=rich_editing]:after { content: '.)'; }
</style><?php
}

It removes the checkbox and displays the message:'The option to enable the visual editor has been removed (in functions.php). (Formerly:Disable the visual editor when writing.)

In that message, I want to remove '(Formerly:Disable the visual editor when writing.)' but have no idea how and various trial and error hasn't yet worked.

mindgamez83 on "Sports Score Ticker"

$
0
0

Hey im running a gaming community, im looking to add a sports score ticker like espn has. Something that i can update manually. I ve searching everywhere. If this is unappropriate i apologize

bighearts on "Our site has been hacked"

$
0
0

How do I get rid of viagra pop-ups and virus warnings on site.

Bbaale on "I need help on how to add selected()"

$
0
0

Am coding a plugin which creates a wigdet where a user selects from the available categories but I don't how to add selected() and how to check if user selected any option. Below is my code.

<p>
	<label for="<?php echo $this->get_field_id('select'); ?>"><?php _e('Select featured Category', 'wp_widget_plugin'); ?></label>
	<select name="<?php echo $this->get_field_name('select'); ?>" id="<?php echo $this->get_field_id('select'); ?>" class="widefat">
 	<option value=""><?php echo esc_attr(__('Select Category')); ?></option>
 <?php
 $args = array('orderby' => 'name', 'parent' => 0 );
  $categories = get_categories($args);
  foreach ($categories as $category) {
  	$option = '<option value="'.$category->cat_ID.'">';
	$option .= $category->cat_name;
	$option .= ' ('.$category->category_count.')';
	$option .= '</option>';
	echo $option;
  }
 ?>
	</select>
</p>

tnoguchi on "Display Groups of Custom Posts by their Custom Taxonomy Term"

$
0
0

Hi,

I'm trying to output a portfolio page composed of sections of CPT post thumbnails organized by their custom taxonomy term slugs.

While it's easy for me to output the terms associated with the custom taxonomy, I'm not sure how one nests a custom query to retrieve the posts associated with each term in the foreach loop.

I've included the code that I've worked on; but this is a bit beyond my PHP skill level.

//retrieves an array of the terms as slugs
$terms = get_terms('tn_cstm_work_taxonomy', 'fields=names');

// This returns all posts in the custom taxonomy, rather than posts for each term
    $projectsArgs = array(
            'tax_query' => array(array(
                    'taxonomy' => 'tn_cstm_work_taxonomy',
                    'field' => 'slug',
                    'terms' => $terms
            ))
          );

        foreach ( $terms as $term ) {        ?>
      <div class="row">
//Populates the the section and titles with the slug; needed for navigation
        <section id="<?php echo $term; ?>" class="large-12 columns" data-magellan-destination='<?php echo $term; ?>'>
           <h3><?php echo $term; ?></h3>
           <ul class="large-block-grid-4 small-block-grid-2">

            <?php
            $projects = new WP_Query($slug); while ($projects->have_posts()) : $projects->the_post(); ?>

              <li>
                  <?php
                        //outputs thumbnails for gallery
                         if(function_exists('tn_cstm_work_thumb')) {
                          tn_cstm_work_thumb();
                    ?>
              </li>

            <?php endwhile; wp_reset_postdata(); ?>

          </ul>
        </section>
      </div><!-- .row -->     

<?php } ?>

This is obviously incorrect, the custom query will just pull all of the posts associated with any term in the custom taxonomy. Is there a way to output just the posts associated with each term?

Any hints, or help would be appreciated.

Thanks!


DoodleDogCody on "Register Post Type - Capability Type (nav menu item)"

$
0
0

I am wondering if it is possible to create a custom post type that behaves like a nav menu in the Admin area.

Basically I am working on a card tournament project that will require me to set up different levels in the tournament that consist of a couple different custom fields.

I want these post types to be able to be assigned to different tournaments structures and these tournament structures can be used on any given tournament. I know I could just create a levels custom posttype and then create a structure taxonomy and then assign a level to multiple taxonomies but that relationship is sort of backwards in the way the site will be updated.

The better way would be to have the Structure Post type behave like a menu and then allow me to drag and drop all the different levels that are created into a nav menu like structure.

So hopefully that makes sense. Overall question. Is it possible to create a custom post type has the admin interface of a nav menu

Avi Tannenbaum on "Auto generate template sub-page with username as title"

$
0
0

Hi,
How do I automatically generate a sub page for every user that registers to my site?
I want the title of the automatically generated page to be equal to the username of the user and be placed with a certain page template.
Any help out there?

here is my website:
http://www.StarShowsStudios.com

cold_ on "Modify slugs with own algorithm"

$
0
0

Hi there,

I need to get rid of accents of the title being replaced to latin equivalents. For instance from a title 'Hôpital' the post slug will be 'hopital', but I have to get 'hpital'.

I managed to add this to functions.php:

add_filter('post_link','postLinkFilter', 10, 3);
function postLinkFilter($permalink, $post){
	$slug = preg_replace('~([^a-z0-9\- ])~i', '', $post->post_title);
	$slug = strtolower(str_replace(' ', '-', trim($slug)));
	$slug = preg_replace('~\-\-+~', '-', $slug);
	return '/'.$slug;
}

It creates the right slug, replaces links all over the site, but I still can't access posts with the new slug (so it's not changing the slugs in real, just changing links on the site...).

Any idea? Thank you in advance!

[Moderator Note: No bumping. If it's that urgent after waiting just 1 hour, consider hiring someone instead.]

IqraShahid123 on "Short Code Ordering."

$
0
0

Hi,
I have created the short code that display some text. When I display the content it's order changes.
I want my data of short code should appear before the body content.

Any advice for this.
Thanks,

taiki_d on "WordPress PHP Form Code Error"

$
0
0

Hi all,
I'm looking for a bit of help. I'm a bit of a noob when it comes to php and I've put together the following code. What I'm trying to do is give the subscriber 3 dropdowns, and I then want to use those three dropdowns as well as their Surname as found in their user info to rename a file they are uploading. This is what I have so far, but I keep getting errors saying that wp_get_current_user is a call to an undefined function etc... Can anyone pls help?

<?php
require_once('/wp-includes/pluggable.php');
global $current_user;
$current_user = wp_get_current_user();
$current_user->user_lastname;
 $submittedValue = "";
 $submittedValue1 = "";
 $submittedValue2 = "";
        $value0 = "";
        $value1 = "FMOT";
        $value2 = "FMBM";
        $value3 = "FMCC";
		$value4 = "FMHS";
		$value5 = "FMSP";
		$value6 = "FMFin";
		$value7 = "FMSS";
		$value8 = "Assignment";
		$value9 = "Assignment Attachment";
		$value10 = "Logbook";
		$value11 = "Logbook Attachment";
		$value12 = "1";
		$value13 = "2";
		$date = date('Y m d H i s');
	if (isset($_POST["Subject"])) {
            $submittedValue = $_POST["Subject"];
        }
	if (isset($_POST["DocType"])) {
            $submittedValue = $_POST["DocType"];
        }
	if (isset($_POST["AssNo"])) {
            $submittedValue = $_POST["AssNo"];
        }
// Your file name you are uploading
$file_name = $HTTP_POST_FILES['ufile']['name'];

// random 4 digit to add to our file name
// some people use date and time in stead of random digit
$random_digit=rand(0000,9999);

//combine random digit to you file name to create new file name
//use dot (.) to combile these two variables

$new_file_name= $user_lastname.$submittedValue.$submittedValue1.$submittedValue2.$date.$file_name;

//set where you want to store files
//in this example we keep file in folder upload
//$new_file_name = new upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path= "wp-content/uploads/assignment/".$new_file_name;
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "Successful"; 

//$new_file_name = new file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
echo "File Name :".$new_file_name."";
echo "File Size :".$HTTP_POST_FILES['ufile']['size']."";
echo "File Type :".$HTTP_POST_FILES['ufile']['type']."";
}
else
{
echo "Error";
}
}
?>

My Form Code:

<form action="getfile.php" name="a4fm" method="post">
        <select project="Subject" id="Subject" name="Subject">
         <option value = "<?php echo $value0; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value0; ?></option>
         <option value = "<?php echo $value1; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value1; ?></option>
         <option value = "<?php echo $value2; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value2; ?></option>
         <option value = "<?php echo $value3; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value3; ?></option>
		 <option value = "<?php echo $value4; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value3; ?></option>
		 <option value = "<?php echo $value5; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value3; ?></option>
		 <option value = "<?php echo $value6; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value3; ?></option>
		 <option value = "<?php echo $value7; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value3; ?></option>
        </select>
		<select project="DocType" id="DocType" name="DocType">
         <option value = "<?php echo $value0; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value0; ?></option>
         <option value = "<?php echo $value8; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value1; ?></option>
         <option value = "<?php echo $value9; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value2; ?></option>
         <option value = "<?php echo $value10; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value3; ?></option>
		 <option value = "<?php echo $value11; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value3; ?></option>
        </select>
		<select project="AssNo" id="AssNo" name="AssNo">
         <option value = "<?php echo $value0; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value0; ?></option>
         <option value = "<?php echo $value12; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value1; ?></option>
         <option value = "<?php echo $value13; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value2; ?></option>
        </select>
        Type (or select) Filename: <input type="file" name="uploadFile">
		<input type="submit" value="Upload File">
        </form>
Viewing all 8245 articles
Browse latest View live




Latest Images