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

Hube2 on "Prevent update to 4.0 from altering a table column"

$
0
0

I am using a plugin, and due to the way that plugin creates "option_name" values, these names can exceed the 64 character limit of the "options_name" column in the DB.

You can read about this issue here and how it has been discussed but nothing done about it for 4 years. https://core.trac.wordpress.org/ticket/13310#comment:33

So, I have been forced to modify the table myself to make the size 255 rather than 64. The problem is that I cannot update one of my sites to 4.0 because the update causes the column width to be changed, truncating all of the long option_name values to 64, which completely breaks the site.

What I need is information on how to prevent the update from modifying that table column. I have tried this, it does not work on this table: http://codex.wordpress.org/Editing_wp-config.php#Do_not_upgrade_global_tables

Any help on how I can hook into the update process to prevent this change would be greatly appreciated.


barbara690 on "WatuPro Display problems"

$
0
0

Has anyone been using Watu Pro? I'm having problems getting the quiz results to display properly. I've used the shortcodes from their CalendarScripts Blog but, while I finally got it to display mostly the proper data, it also displays the script: %%ANSWERS%% %%GRADES%% after the data. It looks really bad and unprofessional.

Any ideas how to handle this?

wcten on "Comment Template"

$
0
0

How do I make a new comment template that when I click on the user name, and it link me to the page that will show all the comments made by that particular user?

I have the following code that show only admin's comments.

<?php
/*
Template Name: Comments Template
*/
?>
<?php get_header(); ?>
<div class="content-wrap">
	<div class="content">
		<?php tie_breadcrumbs() ?>

		<?php
$args = array(
	'user_id' => 1, // use user_id

);
$comments = get_comments($args);
foreach($comments as $comment) :
	echo($comment->comment_author . '<br />' . comment_excerpt( $comment_ID ));
endforeach;

?>

<?php get_sidebar(); ?>
<?php get_footer(); ?>

Cibeles on "Adding php code into Contact Forms 7"

$
0
0

Good morning,

I've got a problem I can not solve and I hope you can help me out.

I am using contact forms 7 and I need to show some more fields (also generated with same plugin) depending if a checkbox is checked or not.

So thing is "Do you like tea?" and if checked print some fields to get more details, after that, the submit button has to send me the fields I printed before this answer and the fields after it.

Is this feasible? Can I add php to contact form 7?

Thanks

lilts520 on "Contact Form 7 Checkboxes/radio buttons"

$
0
0

Hello,

I have posted in the specific plugin forum, but got no replies. Hoping someone can help!

I am trying to figure out how to assign classes to content rendered from within a shortcode. I need to style parts of checkboxes as bold but Contact Form 7 short code for Checkbox doesn't register my class assignments as html, but rather as text. So, for instance, I have a shortcode that says [checkbox "item1" "item2" "item3"], and I would like the numbers in each item to be bold. How can I go about this?

Basically, is there anyway to force the plugin to read some of the content within a shortcode as html rather then text?

Any help is greatly appreciated! Thanks!

Santhosh on "Adding parent menu items page content inside main menu"

$
0
0

Hi,

I am having a main menu. So what i need is i want to display the content(like featured image and some excerpt) of the parent menu pages inside the main menu. So for each menu with submenus there will an image and some content which of its respective parent menu link.

Please help me out with this.

Thanks.

MrRojiiR on "Feeds, Custom Post and URL Mapping"

$
0
0

Hello, I'm not a novice in wordpress, I actually work on several Wordpress Blog or building wordpress showcase site.

But I search something new, a way to collect content from other websites with RSS, ATOM etc for example, and automatically create a content in a custom post type that I have already create, the hard part is to succeed to automatically matching the permalink of the custom post with the external URL of the source of the content (RSS etc...)

Any Idea of how i will do that ? Or a list of plugins I can use for it ?

PS: Sorry for the approximately english This is not my native language.

Maikel1987 on "Facebook and Twitter code"


PEBKACfr on "show an image when clicking on datepicker"

$
0
0

Hi,

I would like to show an image depending of a date choosen on datepicker.

First step i have added in functions.php of my theme:
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');

Then in page.php of my theme i have added the function below:

<script type="text/javascript">

jQuery(document).ready(function() {
jQuery('#MyDate').datepicker({
dateFormat : 'DD, d MM, yy',
numberOfMonths: 2,
inline: true,
minDate : -7,
maxDate : +30,
altField: '#MyDate_value',
onSelect: function(){
var day1 = $("#MyDate").datepicker('getDate').getDate();
var month1 = $("#MyDate").datepicker('getDate').getMonth() + 1;
var year1 = $("#MyDate").datepicker('getDate').getFullYear();
var fullDate = year1 + "-" + month1 + "-" + day1;
var str_sortie = "<img src=\"http://www.adress.com/" + fullDate +".jpg\">";
image_sortie.innerHTML = str_sortie;

}
});

});

</script>

3) In a wordpress page i have added

<!-- Datepicker -->

<div id="MyDate"></div>

<p>Image selected of the date <input type="text" id="MyDate_value" /></p>

<div id="image_sortie" style="text-align:center; margin-top:10px; margin-bottom:20px;"></div>

As a result on the page:
- i have the datepicker calendar for 2 months
- when i click on a date i have this date showed on the date picker box
- but i haven't got the image selected shown. My link is good because if i write <img src="http://www.adress.com/2014-10-01.jpg" /> for exemple for the picture of the 1st of octobre, i have got the picture showed.

I try to search but i don't find anything. If somebody understand in wich line the problem could be, could you exmplain me what to do ?

Thank you a lot and excuse me for my english.

orbetllc on "Show field based on user role (if else)"

$
0
0

Hi everyone,

I just need a little bit of help with an if else to show a custom field I have created to users based on their user role.

If they are a certain user role, or even a certain user role and/or higher i was this to show

<p>MAP: <?php the_field('map'); ?></p>

I can't seem to figure it out after looking around all day.

lachender_engel on "Limit for Custom Post"

$
0
0

Hello Guys.

I hope I can get a solution from you for the following issue:
I use Polylang to get a multilingual web site. This works perfect.
Additional I’ve created a custom post type with Polylang support. Works also very nice. And I use custom roles with capabilities to give a role the right to add a new custom post and save it. Everything works as expected.

Now, I would like to add a limit to allow the role to add only one post per language.

For this I wrote a function which checks how many languages are activated and how many posts in which language are already saved for the customer. One goal is to disable the “new post” button on the top of the list where Wordpress shows all custom posts. The second goal is to disable or hide the “save” button on the edit page.

Now, my questions are:
1.) Where can I call the function to check the posts? Is there any hook (or some other place) which is called before Wordpress shows the list of the custom posts?

2.) How can I disable or switch off the “new post” at the top of this list? Important is, I have to do it without Java Script (jQuery) to prevent the user disables JS and can add an additional post.

3.) How can I disable or hide the save button on the edit screen/dialog, also without jQuery?

Hope I made clear what I need and I hope more, you can give me a hint or the solution ;-)

Thanks a lot in advance!

Booka800 on "[Plugin: WPL] Adding WP User into WPL with User Role Specific Membership"

$
0
0

I posted this in plugins last night and was then told to try the hacks section. I STINK AT PHP. You've been warned. I haven't no freaking clue what I'm doing.

I use the WPL plugin which automatically adds new WP users into the WPL database. I am trying to figure out how to have the new users added based on their WP roles. In WPL, there are different memberships. The new users should fall into different memberships based on their WP role. Right now, everyone falls into the default membership.

public static function add_user_to_wpl($user_id)
	{
		/** first validation **/
		if(wpl_users::get_wpl_user($user_id)) return true;

		$user_data = wpl_users::get_user($user_id);
		$default_data = wpl_users::get_wpl_data(-1);

		$forbidden_fields = array('id', 'first_name', 'last_name');
		$auto_query1 = '';
		$auto_query2 = '';

		foreach($default_data as $key=>$value)
		{
			if(in_array($key, $forbidden_fields)) continue;

			$auto_query1 .= "<code>$key</code>,";
			$auto_query2 .= "'$value',";
		}

		if($user_data)
		{
			$auto_query1 .= "<code>first_name</code>,<code>last_name</code>,";
			$auto_query2 .= "'".$user_data->data->meta['first_name']."','".$user_data->data->meta['last_name']."',";
		}

		$auto_query1 = trim($auto_query1, ', ');
		$auto_query2 = trim($auto_query2, ', ');

		$query = "INSERT INTO <code>#__wpl_users</code> (<code>id</code>, ".$auto_query1.") VALUES ('".$user_id."', ".$auto_query2.")";
		$result = wpl_db::q($query);

        /** trigger event **/
		wpl_global::event_handler('user_added_to_wpl', array('id'=>$user_id));

		return $result;
	}

This line from above (I believe) tells the new data to fall into the default membership (-1) is the ID of the default membership).

$default_data = wpl_users::get_wpl_data(-1);

This code comes from WPL's users.php

I feel like I just need some 'if' statements here but I do not know much about PHP and need some massive help. I've been working with WPL but I ran out of money so they won't help anymore. C'est la vie.

My previous post is here in the plugin forum. It has more info.

Any help would be appreciated. It's my last issue to be resolved - so frustrating!

webstan on "deactivate_plugins after version check not working"

$
0
0

Hello,

I am busy trying to learn more about making plugins. I want to make my plugin unable to activate if the version number of wordpress is lower then the one i give. I used the following code:

register_activation_hook( __FILE__, 'st_testplugin_install' );

function st_testplugin_install() {
	if ( version_compare( get_bloginfo( 'version' ), '4.1', '<' ) ) {
		deactivate_plugins( plugin_basename( __FILE__ ) );
	}
}

After using this code my plugin is still able to activate. It seems like it doesn't run the deactivate_plugins somehow. My wordpress version is 4.0 so lower then the 4.1 i gave in the version_compare function. I was wondering if someone could help me with this and can tell me what I am doing wrong.

Jonas on "wp_schedule_event and delete post"

$
0
0

Hello

First of all: I'm a newbie. This is the first time I code something in PHP. So I need a plugin to automaticly delete posts after 24 hours. Because I couldn't find a plugin with the featrue I need, I decided to code my one one. So I tried something.
In this code I set the time, when a post should deleted. (Maybe it's wrong)
$timestamp = time(); //Gets the seconds since 1.1.1970
$time = date("d.m.Y-H:i", $timestamp); //Formats the seconds in the actual time
$calculateTime = strtotime($time) + 24*3600;  // adds 24h to the timestamp (24*3600=24h)
$FormatedTime = date("d.m.Y-H:i", $calculateTime); //Formats the calculated date

$deleteTime = $FormatedTime; //Sets a better understandabel value.

Next I implemented this:

wp_schedule_event($deleteTime, $daily, do_action('delete_post', 2488));

2488 Is the post ID that I test with. I understand that daly at the $deleteTime the post should be deleted, but it doesn't work.

My second question is:

I'd like that every post in a defined category will be deleted after 24h. So I write something like this. (But it is't true i guess...)

if (in_category(43))
{

//code here
}

Thanks a lot for every help!

evanpyrz on "Modification to Theme to Add Image Link"

$
0
0

Hi there,
I have a general working knowledge of PHP and HTML, but am fairly new to coding for WordPress. Hoping this topic doesn't seem too far-fetched for a forum. What I am trying to do is modify an existing theme I have, to add a URL to a post's image to the HTML rendered. I though I had made the correct modification, however, I am unable to get WordPress to set my $Img variable to the post's data.

This is what I have:

function cro_menuq_func( $atts ) {

    extract( $atts );

    $img = get_the_post_thumbnail( $post_id );
    $op = '<div class="quickiemenu">';

    if (isset($title) && $title != '') {
        $op .= '<a href="'. $img .'"><span class="quickietitle cro_accent">' . stripslashes($title)  . '</span></a>';
    }

    if (isset($desc) && $desc != '') {
       $op .= '<span class="quickiedesc">' . stripslashes($desc)  . '</span>';
    }

    if (isset($price) && $price != '') {
       $op .= '<span class="quickieprice cro_accent">' . stripslashes($price)  . '</span>';
    }

    $op .= '</div>';

    return $op;

}
add_shortcode( 'cro_menuq', 'cro_menuq_func' );

I've contacted the theme's developer as well, but they have yet to get back to me, so I wanted to see if someone on here saw something standing out to them.

I'd be happy to provide reference to this entire file if needed.

Thanks in advance,

Eric


coderdj412 on "Filter: CPT and map_meta_cap"

$
0
0

If I set map_meta_cap to true in cpt, do I have to create a map_meta_cap filter if I don't want to? or does that have to be created in order to properly use it?

If I set map_meta_cap in cpt and don't add a map_meta_cap filter, it will just use the core map_meta_cap correct

Kristoff1875 on "Filter posts by 2 parent categories?"

$
0
0

Hi guys, i'm a novice at Wordpress, please bare with me.

Say we have 2 Parent categories CatA and CatB, and 2 dropdown selections that each contain the child categories CatAdropdown contains CatA child categories and CatBdropdown contains CatB child categories, would it be possible to filter results by using both of these? So once you choose an option from each dropdown and click go, you get posts that only have both categories selected? I'm thinking something along the lines of when you send the query:

if ((CatA == 1) && (CatB == 7)) { query_posts(array('category__and'=>array(1,7))); }

Would something like this be possible?

Thanks in advance

Wsan1 on "Java Code through Plugin?"

$
0
0

Can the plugin be Modified to only include the javascript files for the "checked" sites?

Recently, my site had 1 page that had what Bing deemed Malicious Java script & I am wondering if it got in through a plugin.

the java script had, after my root site url the following extension wp/wp-includes/js/masonry.min.js

I don't know if I am giving specific enough information to render a response. If not, please ask me more questions. I am only superficially familiar with such an issue. My tech person wanted me to ask the question at the top bec a plugin source seems to be the thought of how the unwanted Java script got on a page.

Thank you for your consideration

DoodleDogCody on "custom taxonomy pagination"

$
0
0

I have a custom post type called ddc_products and a custom taxonomy called ddc_product_categories.

The products template works just fine for all pages in the pagination. But the taxonomy template is only being read on the first page of products shown. I know this because in my template I force my themes full width layout but the 404 that is returned to me is the default theme layout. Has anyone had this kind of problem before.

Here is the code used in the taxonomy template file.

<?php

remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'custom_loop');

function custom_loop() {

	$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
	$id = $term->name;

	$args = (array(
		'post_type'    => array( 'ddc_products' ),
		'ddc_product_categories' => $id,
	));

	genesis_custom_loop( $args );

}

remove_action('genesis_entry_content', 'genesis_do_post_content');
add_action('genesis_entry_content', 'ddc_products_content', 1);

function ddc_products_content() { ?>

	<a href="<?php the_permalink() ?>"><?php the_post_thumbnail('thumbnail'); ?></a>

<?php }

remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );

add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );

genesis();

Yes, this is using a genesis theme. But even when switching to the default 2014 the taxonomy page isn't working correctly

ryanbowden on "wp_query args adding muitiple tax_querys"

$
0
0

I am creating a custom search system which search my custom post type recipes, in the search it searches the taxonomies terms that people have selected.

Now due to the way it can hard code all these i need to build the args by a loop of some sort.

Here a code example if what i have,

$args = array(
'post_type'      => get_post_type(),
'orderby'        => 'menu_order',
'order'          =>  'ASC',
'posts_per_page' => -1,
'no_found_rows'  => true,
'tax_query' => array(
    'relation' => 'AND',
    array(
        'taxonomy' => 'product_category',
        'field'    => 'slug',
        'terms'    => array($category->slug), //Supply the current product_category terms
    ),
    array(
        'taxonomy' => 'product_locations',
        'field'    => 'slug',
        'terms'    => array($current_location), //Add the product_locations term
        'operator' => 'IN',
    ),
),
);

What i need is to add:

array(
        'taxonomy' => 'product_category',
        'field'    => 'slug',
        'terms'    => array($category->slug), //Supply the current product_category terms
    ),

What i need is to add them programmatically when a person selects i have tried build the args array with loops and adding strings together but i can't get it to work. Does anyone have any quick way it can be done?

Viewing all 8245 articles
Browse latest View live




Latest Images