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

andrejcremoznik on "Bringing script/style registering out of the stone age"

$
0
0

Welcome to 2016. Frontend build tools make it super easy to allow us creating script bundles of different libraries. Yet, there's just no way to effectively handle script bundles with WordPress's script registering/enqueuing functions.

For future reference, when I say script bundle I'm refering to a single Javacript file that includes multiple libraries like jQuery, Underscore, Backbone and others present on WordPress core.

When creating a WordPress website for a single client (as opposed to a feature rich, non-/commercial template) I'm in control of plugins being used. And I want to be able to handle all their dependencies manually by deregistering scripts they load and provide my own script bundle. This is impossible to do because there's no way of registering a script with multiple handles.

So please, can we have the $handle param in wp_register_script() be an array allowing developers to load a single script bundle of multiple libraries?

P.s. Please don't start an argument about how I'm being stupid for wanting this. My reason is clearly stated above and I want you to accept it as it's written.


jacaldwell on "Default Email Message Text"

$
0
0

Can anyone tell me where I can find the text that is used in the default email templates?

I am not looking for a plug-in or how to write a plug-in. I am not looking to add images, backgrounds, HTML, or Responsive Design elements. I only want to change 3 little words used in one of the messages. Can anyone help point me to where the text copy for default email messages may be found?

TIA

ccarlow on "need to get post and/or page ID - need input on php code"

$
0
0

I am writing some php code for header and footer sections using an if statement to decide if a section of code gets executed or does not. I never wrote php before.

Can someone look at my code and tell me why it's not working?

<!-- set list of specific post and/or page id's in an array called $cl -->
<?php $cl == array(4708, 4534, 4533, 4531, 4530, 4529, 4528, 4832, 4833, 4666, 4665, 4659, 4657); ?>
<!-- if NOT post-or-page-ID in $cl then "SHOW THIS" -->
<?php if (!in_array($post->ID, $cl)) : ?>
show this
<?php : ?>

I want to compare the page or post ID with a list of ID's and use an if statement to determine is ID exists or not in the list.

This below php if statement code was working for me except it only worked on page ID's and not post ID's.

Guido on "Sender and Return-Path in PHPmailer"

$
0
0

Hi,

For my contactform I was using this to set Sender / Return-Path (to avoid getting messages in Junk/Spam folder):

function my_phpmailer_return_path( $phpmailer ) {
	$phpmailer->Sender = $phpmailer->From;
}
add_action( 'phpmailer_init', 'my_phpmailer_return_path' );

I now notice this is apparently not supported anymore, Sender / Return-Path are now my hosting provider email.

When I take a look at file class-phpmailer.php I notice this info above $Sender:

The Sender email (Return-Path) of the message.
If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.

I don't understand the 'If not empty' part.. Is Sender still supported? If it is, is my function deprecated?

I do know Return-Path is not supported anymore, but what about Sender?

Guido

alex1nd on "paginate_links in category.php NOT WORK"

$
0
0

it works everywhere, except category.php
nothing turns me what to do
----------------------------------

<?php endwhile; ?>
<!--Post navigations-->
<?php
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );
?>
<?php else: ?>

spockisbest on "Dreamweaver CS3 URL issue"

$
0
0

Hey,

I just created my website last month, and I finally began updating it. Here's the issue: I connected Dreamweaver CS3 to my domain to act as an FTP for uploading. The issue is that I want my website .com to be the landing page, but the .com page is the wordpress site. So I either need to figure out how to make my landing page have the .com url (as opposed to the .com/index url), OR, I need be able to edit my wordpress .com with the content from my landing page.

tldr;

My website: todiscern.com
My landing page: todiscern.com/index

I need the landing page to occur when someone types in todiscern.com, so however that happens, that would be awesome. Also, I was an idiot and used a theme, and now I can't disable it. Am I stupid? Probably. Help?

laonikoss on "JS script loads through wp_enqueue but does not work."

$
0
0

Here's my problem (I posted this under plugins, so am reposting here because it wasn't the right place!) (And I can't seem to edit/move/delete my previous post anymore.)

I have a js script that I want to load to the page. If I hard-code it onto the <head> section of header.php (including loading an external minified jquery, http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js ) it works just fine.

However, if I remove the link to the external jquery file, it stops working.

If I try to load the script through wp_enqueue (functions.php), it loads just fine (I can see it loaded in the <head> section, and if I click on the link it opens the file, so it links to the correct file), but it still doesn't work.

What could be the problem?

Here is the original script:

$(function() {
    $(window).on('scroll', function() {
        $('#par_background').css('margin-top', $(window).scrollTop() * -.3);
    });
});

 $(document).ready(function () {
    $(window).bind('scroll', function () {
        var distance = 50;
        if ($(window).scrollTop() > distance) {
            $('nav').addClass('scrolled');
        } else {
            $('nav').removeClass('scrolled');
        }
    });
});

And here's the modified content of test.js file, formatted to load with wp_enqueue (but I am not confident at all if this is the correct formatting, not an expert with JS):

jQuery(function() {
    $(window).on('scroll', function() {
        $('#par_background').css('margin-top', $(window).scrollTop() * -.3);
    });
});

jQuery(function () {
    $(window).bind('scroll', function () {
        var distance = 50;
        if ($(window).scrollTop() > distance) {
            $('nav').addClass('scrolled');
        } else {
            $('nav').removeClass('scrolled');
        }
    });
});

Any help would be appreciated!

Mike_Oberdick on "Art Gallery using Custom Post Type and Custom Taxonomy"

$
0
0

I'm working on a website for an artist. I have created a CPT called "artwork" and custom taxonomies for the attributes of each piece of work. One of the custom taxonomies is "album" which supports a hierarchy so that a user can navigate through the gallery. It is working somewhat here if you click on "2014" and then "Flowers". What I'm missing is a thumbnail image for each folder that is pulled from the actual artwork (grandchild of parent term). Here is my code from the taxonomy-album.php file:

<?php get_header(); ?>

<div class="container clearfix">
		<header class="entry-title">
			<h1 class = "archive-title"><?php single_cat_title(); ?></h1>
		</header>

<h3 class = "category_description"><?php echo category_description(); ?> </h3>

<div class = "taxonomy_thumbnails">

<?php

$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); // get current term

$parent = get_term($term->parent, get_query_var('taxonomy') ); // get parent term

$children = get_term_children($term->term_id, get_query_var('taxonomy')); // get children

if(($parent->term_id!="" && sizeof($children)>0)) {

// set the args for wp_list_categories

$args = array(
    'child_of' => $term->term_id,
    'taxonomy' => $term->taxonomy,
	'order' => DESC,
	'hide_empty' => 0,
	'hierarchical' => true,
	'depth'  => 1,
	'title_li' => ''
    );

wp_list_categories( $args );

}elseif(($parent->term_id!="") && (sizeof($children)==0)) {

?>

<div class = "archive_thumbnail_box">

<?php

	$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' );
	echo '<a href="' . $large_image_url[0] . '">';
	the_post_thumbnail( 'thumbnail' );

	echo '</a>';

?>

<span><?php echo get_the_title(); ?></span>

</div><!-- .archive_thumbnail_box -->

<?php

}elseif(($parent->term_id=="") && (sizeof($children)>0)) {

// set the args for wp_list_categories

$args = array(
    'child_of' => $term->term_id,
    'taxonomy' => $term->taxonomy,
	'order' => DESC,
	'hide_empty' => 0,
	'hierarchical' => true,
	'depth'  => 1,
	'title_li' => ''
    );

wp_list_categories( $args );

}

?>

</div> <!-- end of .taxonomy_thumbnails -->

</div> <!-- end of container -->

<?php get_footer(); ?>

keytastic on "Auto Gallery Repeated Images"

$
0
0

I write on my site using the mobile iOS app a lot and I've noticed that it's not currently possible to insert a gallery from it (except for manually typing out the shortcode, of course). Obviously, it would be most ideal for WordPress to just fix this in the app, but I've also found that it would be convenient--even on a desktop browser--if when you insert several images in a row it would automatically convert them to a gallery.

How difficult would it be to code a plugin to do this? It would need to grab the image IDs from the <img> tags and then construct the shortcode [gallery type="rectangular" ids=""].

Kia on "Comment comes in to my wp_comment"

$
0
0

There is no comment form in my website. But spam comments come in to wp_comment. Is this code hijacking? How can I find those files? Thank you.

slydawggiex916 on "Exit Overlay or Lightbox issue"

$
0
0

I am trying to code, or find the code/plugin, to allow for the following scenario to work...

If there is one link on my page that goes to an external link and it opens a new window for that link, if the user comes back to my site there is an overlay would then be there. This action doesn't even have to happen on a returnto action, but could be one action that when clicked, an overlay is placed while a new window is opened. I do not mind if it is a CSS, Javascript, or AJAX fix - I am just having trouble making that happen.

scapel on "Create page and content"

$
0
0

Hello,
I'am a beginer in plugin développement, and i am trying to create a page with an form inside...
I create a class in which i use wp_insert_post and it is ok, but now, i don't know how(or where!?) should i write code for my form...
This class is instancied from admin menu.

That's an extract of code:

<?php
class register_page
{
	private $id_page;

	public function __construct()
	{
		//Cree une page
		$my_post = array(
				'post_title'    => 'Inscription Individuelle Generee',
				'post_content'  => 'This is my Page.',
				'post_type'		=> 'page',
				'post_status'   => 'publish',
				'post_author'   => 1,
		);

		// Insert the post into the database
		$id_page = wp_insert_post( $my_post );

		//
		//add_action('the_post', array($this,'register_page_construct'));
		add_filter('publish_post', array($this,'register_page_construct'));

		// write in table a log to controle this code is active
		include_once plugin_dir_path( __FILE__ ).'/sql_tool.php';
		$sqlTool = new sql_tool();
		$sqlTool->debug_log("creation de la page");

	}

	public function register_page_construct($content)
	{
//		if ( is_page ($id_page) )
//		{
			echo "<h1>COUCOU</h1>";

		    //write in table a log to controle this code is active
			include_once plugin_dir_path( __FILE__ ).'/sql_tool.php';
			$sqlTool = new sql_tool();
			$sqlTool->debug_log("page_chargee");
//		}
	}

}
?>

Please help me!
Thanks,
Sebastien

toneburst on "OOP Widget Delete Plugin Options on Uninstall"

$
0
0

I'm working on a widget plugin, made using the method of extending the builtin WordPress Widget class, based on the tutorial here.

My widget has a number of options, set using the following method of the extended widget class:

public function update( $new_instance, $old_instance ) {

	$instance = array();
	$instance[ 'title' ]					= ( ! empty( $new_instance[ 'title' ] ) ) ? strip_tags( $new_instance[ 'title' ] ) : '';
	$instance[ 'ellcv_category' ]			= ( ! empty( $new_instance[ 'ellcv_category' ] ) ) ? $new_instance[ 'ellcv_category' ] : '';
	$instance[ 'ellcv_displayTitle' ]		= isset( $new_instance[ 'ellcv_displayTitle' ] ) && 'on' == $new_instance[ 'ellcv_displayTitle' ] ? true : false;
	$instance[ 'ellcv_displayExcerpt' ]		= isset( $new_instance[ 'ellcv_displayExcerpt' ] ) && 'on' == $new_instance[ 'ellcv_displayExcerpt' ] ? true : false;
	$instance[ 'ellcv_displayLink' ]		= isset( $new_instance[ 'ellcv_displayLink' ] ) && 'on' == $new_instance[ 'ellcv_displayLink' ] ? true : false;
	$instance[ 'ellcv_excludeCategory' ]	= isset( $new_instance[ 'ellcv_excludeCategory' ] ) && 'on' == $new_instance[ 'ellcv_excludeCategory' ] ? true : false;
	$instance[ 'ellcv_hideOnSinglePost' ]	= isset( $new_instance[ 'ellcv_hideOnSinglePost' ] ) && 'on' == $new_instance[ 'ellcv_hideOnSinglePost' ] ? true : false;
	$instance[ 'ellcv_maxPosts' ]			= ( ! empty( $new_instance[ 'ellcv_maxPosts' ] ) ) ? intval( $new_instance[ 'ellcv_maxPosts' ] ) : 5;
	$instance[ 'ellcv_maxPostAge' ]			= ( ! empty( $new_instance[ 'ellcv_maxPostAge' ] ) ) ? intval( $new_instance[ 'ellcv_maxPostAge' ] ) : null;
	$instance[ 'ellcv_defMediaURL' ]		= ( ! empty( $new_instance[ 'ellcv_defMediaURL' ] ) ) ? esc_url_raw( $new_instance[ 'ellcv_defMediaURL' ] ) : null;

	// Save site options (required so constructor function can get option before widget loaded)
	update_option( 'ellcv_excludeCat', $instance[ 'ellcv_excludeCategory' ] );
	update_option( 'ellcv_catID', $instance[ 'ellcv_category' ] );

	return $instance;
}

I'd like to be able to remove plugin options on plugin uninstall.

I've created an uninstall.php file for my plugin

<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

// Exit if we don't see the uninstall flag
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
	exit;
}
// Delete site options
delete_option('ellcv_excludeCat');
delete_option('ellcv_catID');
?>

So, I'm able to delete the options set as site options from the database, but what I'm still unclear about is how to also delete the other options, saved/recalled as instance properties from the WP database. I don't know how to get a handle on them to remove them, from my uninstall.php.

I'm hazy on OOP techniques generally, unfortunately, being self-taught, and having been using functional programming techniques for many years.

The code for the entire widget is quite long, so I don't want to post it here, but it's basically the same, structurally as the example I link to above.

Any hints gratefully accepted.

a|x

Any tips

Dariusmit on "Hook for modyfying widget content"

$
0
0

Hello,

I am new with WP development and trying to create WP plugin.

The thing I need to do is to add a html tag buttons for default text widget with ready made html templates when the user press the button. I already got the buttons, but what I can't figure out what filter/action(or none of them) should I use to make that html template (for example <div></div>) to appear into wordpress text widget's content text field?

Thanks in advance!

Regards,
Darius

Dariusmit on "How to generate ID for image"

$
0
0

Hello,

I would like to generate the ID for any image I add into post or widget...

For example when I create new post wordpress automatically generates ID for it, something like "post-879" and the when you go to check page source code you can see that it added <article id="post-879" class="blablabla".... That way you can use CSS for particular post.

What happens with image it only generates <img src="..." alt="">, who no ID??

Thank you in advance!

Regards,
Darius


greguh on "Javascript not running in Wordpress"

$
0
0

Hi,

i'm trying to run Js code into wordpress, using a plugin; but can't make it work.

Here on this Codepen page, you can see the element i'm trying to integrate on my site (ie. a drag and drop feature)

http://codepen.io/galaxija737/pen/pHvEi
And here, this is working properly.

But then, I can't figure out how to integrate the js code properly into wordpress; whatever plugin i'm using. And idem into JSFiddle, impossible to run properly the script, as you can see...
https://jsfiddle.net/szan6shz/)

For instance using "TC-custom-javascript" plugin; when I add the JS code, nothing is running (i.e the drag-drop feature is not working; like ont the Fiddle) :

I'm really new at Javascript as you can see. If anyone can give me a hand on this. (I guess i miss something is the way JS needs to be written/integrated)

Thanks a lot !

Greg

lukeishere on "wp-comments-post.php has updated in WP 4.4, can't stop spam"

$
0
0

Hi all,

In the wp-commens-post.php I used to stop people from posting URL's as this was the main cause of spam and they weren't needed anyway.

I hid the URL box, so if spam users used to post something it just got ignored/blocked.

What I changed is below, also just changed author as well as we were getting a lot of anonymous user arguments.

Just done an WP update and it has all changed, which I don't mind but can't find any sign of where this is to update, Obviously this would be better in the theme/functions file but when I tried a few years ago I couldn't get it to work.

Any help would be appreciated as it worked really well and we'll just get spam if I can't block the url box.

This is my modified code (Line 92 on wp-commens-post.php):

//Below Lukes Code
if(!isset($_POST['author']) || trim($_POST['author']) == "") {
		wp_die( __('Please fill in a name') );
}
else {
	$comment_author = ( isset($_POST['author']) )     ? trim($_POST['author']) : null;
}
//End
$comment_author_email = ( isset($_POST['email']) )   ? trim($_POST['email']) : null;
//Below Lukes Code
if(!isset($_POST['url']) || trim($_POST['url']) == "") {
$comment_author_url = ( isset($_POST['url']) )     ? trim($_POST['url']) : null;
}
else {
		wp_die( __('If you continue to see this message contact us at [email address] ') );
}
//End
$comment_content = ( isset($_POST['comment']) ) ? trim($_POST['comment']) : null;

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

Any help would be much appreciated!
Luke

falldeaf on "Adding functionality to the Media Uploader (gallery for non-images)"

$
0
0

I'm hoping to add functionality to the media uploader that would allow me to create galleries of non-image items. I've added the ability to upload .stl files, but when I use the 'create gallery' functionality it only allows images.

Screenshot of area in the media upload I'm hoping to extend:
https://drive.google.com/file/d/0B0l8k4ni1kjHcDBsNFBxbmpZOUU/view

I'm hoping to add a nav item under 'create gallery' called, 'create STL gallery' that would function the same as galleries (allowing me to select multiple stl files, then re-arrange them, then output a shortcode with id's of stl file uploads. i.e. [viewstl id="230,234,120,233"])

I know html5/js/css3/php but i'm hoping for a hint of which direction to go. I've googled for a while with some search terms like "create gallery media uploader custom functionality extend",. etc. with no luck. I'd really appreciate any direction!

blueclochard on "WP 4.4: remove json-api and X-Pingback from HTTP Headers"

$
0
0

Starting with 4.4 WordPress adds a new HTTP Header. It looks like this:

Link: "<http://www.example.com/wp-json/>; rel="https://api.w.org/""

Does anyone know how to remove it? I know the REST API can be disabled, but I still would like to remove the HTTP Header as well.

Also starting with 4.4 old methods to remove the X-Pingback HTTP Header no longer work. This is the header I am talking about:

X-Pingback: "http://www.example.com/xmlrpc.php"

I would be very happy if anyone could tell me how to remove both of these headers.

ajia.im on "HTTP Response Shows Spam Links but Cannot Locate?"

$
0
0

I have an issue with the website ethicalclothingaustralia.org.au

When I rendered it using Google Webmaster Tools it shows the below nasty code (I'll just copy and paste the top few line as there as a large amount).

<-- WordPressSEOPlugin --><a href="http://pendrive.reklamowe.net.pl/?get-cash-fast-no-credit-checkamphionpro.688883&works=3&workid=68888">Can i earn money by internet</a>
<a href="http://pendrive.reklamowe.net.pl/?how-to-make-real-money-online-for-freedienthoaiben.227392&works=2&workid=22739">Easiest ways to earn money online uk</a>
<a href="http://pendrive.reklamowe.net.pl/?get-cash-fast-no-credit-checkamphionpro.679843&works=3&workid=67984">Online money jobs work legit</a>
<a href="http://parasole.reklamowe.net.pl/?earn-cash-at-homecraton.702862&works=2&workid=70286">Earn money for doing survey jobs</a>
<a href="http://ecofriendlymag.com/?free-way-to-make-moneycubssuckclub.3260618&works=18&workid=32606">How much money can you make youtube partner</a>

I tried to locate WordPressSEOPlugin but it doesn't seem to be installed.

I also searched for links in every single file in the website's directory but could not find any files that contain them.

Any ideas on why these are showing when I fetch them in Google and how I can locate and remove them?

Thanks in advanced!

Viewing all 8245 articles
Browse latest View live




Latest Images