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

samgill on "Site Title seems to be subject to "viagra buy" malware"

$
0
0

On the Site Title on some, but not all pages, the "viagra buy" is added by some malware or something, but it only appears on iPad, not either my MacBook or Mac. I even eliminated the site title and it still appeared by itself. How do I get rid of this?

http://www.Sam-Gill.com It appears on a few of the tabs but not all


Vonneguy on "P2 User Access Restriction by Tags"

$
0
0

Hi All,

I'm using the P2 Theme to create an intranet within WordPress. What I'm looking to do is restrict user access to posts by Tags.

Basically, I only want certain people to have access to certain posts with specific Tags. I've found plugins that allow user/post restriction by Category, but none for Tags.

For instance: for a user, if their name (not username, real-life name) is "Max Power" they would only have access to the posts that are tagged by the Administrator with "Max Power".

Any help would be greatly appreciated!

suntower on "Clicking On View Post In Draft Opens New Tab"

$
0
0

Since 4.0, when you save a post as a Draft the View Post link opens the saved post in a new tab. (target ="_blank")

Is there a way to revert back to the previous behaviour (which was to open the Preview version in the -same- tab?

What's weird is that once the post is published, the saved version opens in the same tab (as in previous WP versions.)

I found that by editing line 93 from edit-form-advanced.php:

10 => sprintf( __('Post draft updated. Preview post'), esc_url( add_query_arg( 'preview', 'true', $permalink ) ) ),

to

10 => sprintf( __('Post draft updated. Preview post'), esc_url( add_query_arg( 'preview', 'false', $permalink ) ) ),

That does what I want (open the Preview in the same tab). HOWEVER, that's hacking the core. Is there a way to get back the old behaviour WITHOUT hacking this file?

It's seriously annoying and frankly I don't understand why this was changed.

TIA,

rudtek on "adding default values for custom field arrays"

$
0
0

I am using a plugin for an events calendar. My client will mostly be starting and stop all events at the same time so i am trying to set default values for the start and stop times. How can i do this? I believe this is the section i would add it to.

$cr3ativconference_fields = array(
	array(
            'label' => __('Date', 'cr3at_conf'),
            'desc' => __('Choose the date.', 'cr3at_conf'),
            'id' => 'cr3ativconfmeetingdate',
            'type' => 'date',
            'std' => ''
        ),
	array(
        'label'    => __('Start Time', 'cr3at_conf'),
        'desc'    => __('Select the start time. 24-hour clock, 01:00-00:30', 'cr3at_conf'),
        'id'      => 'cr3ativ_confstarttime',
        'type' => 'text',
        'std' => ""
    ),
	array(
        'label'    => __('End Time', 'cr3at_conf'),
        'desc'    => __('Select the end time. 24-hour clock, 01:00-00:30', 'cr3at_conf'),
        'id'      => 'cr3ativ_confendtime',
        'type' => 'text',
        'std' => ""
    ),
	array(
            'label' => __('Location', 'cr3at_conf'),
            'desc' => __('Enter location.', 'cr3at_conf'),
            'id' => 'cr3ativ_conflocation',
            'type' => 'text',
	     'value' => 'hawaii',
            'std' => ""
        ),
	array(
            'label' => __('Speaker', 'cr3at_conf'),
            'desc' => __('Select the speakers.', 'cr3at_conf'),
            'id' => 'cr3ativ_confspeaker',
            'type' => 'post_chosen_speaker',
            'std' => ""
    ),
	array(
            'label' => __('Highlight Style', 'cr3at_conf'),
            'desc' => __('Select this checkbox if you would like to have a highlight this session.', 'cr3at_conf'),
            'id' => 'cr3ativ_highlight',
            'type' => 'checkbox',
            'std' => ""
    )
);

Emre on "Can I add categories to Media Files and "search by" option to front end?"

$
0
0

Hi All,

I want to add categories to my pictures. I want to create a WP gallery in front end and also display a search box so my visitors can sort my photos by the categories.

Is something like this possible?

dgcov on "Search for page by content"

$
0
0

I'm trying to find if a page exists and I'm using this clumsy code:

function searchPageContent($contents){
  $pages=new WP_Query( array('post_type'=>'page') );
  if($pages->have_posts()){
    while($pages->have_posts()){
      $pages->the_post();
      $PID=$pages->post->ID;
      $post=$pages->posts[0]->post_content;
      if(substr($post, 0, strlen($contents)) === $contents){
        return $PID;
      }
    }
  }
  return 0;
}

If the page exists which starts with the required content, it returns the Page ID.

This seems to work but is awfully clumsy.

Is there a better way?

andy.newby on "Best way to remove plugins CSS/JS files?"

$
0
0

Hi,

I have a load of CSS/JS files, that I'm trying to merge into just one CSS/JS file. I would use an existing plugin - BUT those tend to make it on the fly (and don't seem to take into account things like ../foo/ URLs). So, I've got the following:

<?php
/*
Plugin Name: My Load Reducer
Description: Removes unneeded and unwanted stylesheets from other plugins
Version: 0.1
*/

//Use a class to avoid conflicts
class my_load_reducer {
    function __construct() {
        //Hook into wp_enqueue_scripts with a high priority
        add_action( 'wp_enqueue_style', array($this, 'deregister_styles'), 99999 );
        add_action( 'wp_enqueue_scripts', array($this, 'deregister_styles'), 99999 );
        add_action( 'init', 'deregister_styles', 99999 );
    }
    function deregister_styles() {
        // remove stuff first...
        wp_deregister_style( 'login-with-ajax' );
        wp_deregister_style( 'contact_form_maker_frontend' );
        wp_deregister_style( 'fontawesome' );
        wp_deregister_style( 'genericons' );
        wp_deregister_style( 'jetpack_css' );
        wp_dequeue_style( 'jetpack_css' );
        wp_deregister_style( 'maxgalleria-image-tiles' );
        wp_deregister_style( 'maxgalleria-image-tiles-skin-standard-css' );

        wp_deregister_script( 'googlemap' );
        wp_deregister_script( 'rwmb-map' );
        wp_deregister_script( 'gmap_form_api' );
        wp_deregister_script( 'gmap_form' );

        wp_enqueue_style( "common-css", '/wp-content/common.min.css' );
    }
}

//Instantiate the class
$my_load_reducer = new my_load_reducer();

What exactly is the different with :

wp_enqueue_style
wp_enqueue_scripts
and
init

For some CSS, the first one is needed - others the 2nd one is needed, and I read somewhere about the "init" function as well (which doesn't seem to do anything for me). One that has been annoying/avoiding me, is the JetPack CSS (I have this in my own CSS file now,so want to skip it);

$version = Jetpack::is_development_version() ? filemtime( JETPACK__PLUGIN_DIR . 'css/jetpack.css' ) : JETPACK__VERSION;

wp_enqueue_style( 'jetpack_css', plugins_url( 'css/jetpack.css', __FILE__ ), array(), $version );
		wp_style_add_data( 'jetpack_css', 'rtl', 'replace' );

I have tried both:

wp_deregister_style( 'jetpack_css' );
        wp_dequeue_style( 'jetpack_css' );

Yet neither seem to work :( (I've disabled W3 TotalCache, just so I can be sure it wasn't a caching issue)

TIA

Andy

wsp-kk on "Write multiple, post-specific category slugs with PHP for"

$
0
0

Dear all:

First off - I am no expert in PHP, but have a working understanding of it, and a fairly good knowledge of HTML and CSS.

This said, I have been working to modify a plugin (specifically, Easy Digital Downloads) to provide front-end users a filter for downloads by one of the multiple category slugs I've tagged each download post with.

You can see an example of the working page here; after all, a picture is worth 1000 words:
http://kidzneurosciencecenter.com/bikesafe-materials/

EDD already limits the downloads that show up by the categories I pull with the shortcode, e.g., [downloads category="bikesafe,schools,parks"].

Problem is, each of the category navigation filters (All Files / BikeSafe / NULL - yes, I'm aware of the coding issue there) are generated by the CSS categories of each download; e.g., if one download reads <div class=BikeSafe Parks post-1923 EDD_downloads..., then the categories "BikeSafe" and "Parks" are generated in the filter bar.

Problem is, I have yet to be able to write the PHP code that will emit the array of slugs unique to each individual download. This is a snippet of the code that writes the DIVs:

$downloads = new WP_Query( $query );
	if ( $downloads->have_posts() ) :
		$i = 1;
		ob_start();?>
		<div class="edd_downloads_list fusion-portfolio-wrapper<?php echo apply_filters( 'edd_downloads_list_wrapper_class', $wrapper_class, $atts ); ?>">
			<?php while ( $downloads->have_posts() ) : $downloads->the_post(); ?>
				<?php $schema = edd_add_schema_microdata() ? 'itemscope itemtype="http://schema.org/Product" ' : ''; ?>
				<div <?php echo $schema; ?>class="<?php echo $terms[0]->slug; ?> fusion-portfolio-post <?php echo apply_filters( 'edd_download_class', 'edd_download', get_the_ID(), $atts, $i ); ?> post-<?php echo get_the_ID(); ?>" id="edd_download_<?php echo get_the_ID(); ?>"  style="width: <?php echo $column_width; ?>; float: left;">

					<?php echo sprintf( '<div class="edd_download_inner">' ); ?>

Obviously, the code that is spitting out the page simply writes "bikesafe" as one of the classes, and I did so simply so everyone here could see how I want it to work. However, I must have tried every single function I could locate online through the WP Codex and other sources, and I still can't get it to spit out the exact slug names per each unique download.

Anyone have some hints here? Tips? Suggestions? I've been at this for a week and a half now, and I'm aware that I've finally come to the point where I need to call the experts in before I get any more white hair.

If you need any extra code, just say the word. Tried to keep this post simple.

Thank you so much!

-Kurt


jangkrik27 on "You do not have sufficient permissions to access this page."

$
0
0

Hi,
I want to add option page to my setting menu but when I click the menu option page I get

You do not have sufficient permissions to access this page.

how I can solve this,? thnks...

wafadul on "Add avatar in New Post widget"

$
0
0

Hi! i just purchased GD bbPress Toolbox and would like to add an avatar to its 'New Post' widget... the author said its possible but im not a coder so i dont know where to start... posted the php file below and would really appreciate any help...

thanks!

<?php

if (!defined('ABSPATH')) exit;

class d4pbbpWidget_newposts extends d4pLib_Widget {
    private $replies = array();

    public $widget_base = 'd4p_bbw_newposts';
    public $widget_domain = 'd4pbbw_widgets';
    public $cache_prefix = 'd4pbbw';

    public $cache_active = true;

    public $defaults = array(
        'title' => 'New Posts',
        '_display' => 'all',
        '_hook' => '',
        '_cached' => 0,
        '_tab' => 'global',
        '_class' => '',
        'period' => 'last_day',
        'scope' => 'topic,reply',
        'display_date' => 'yes',
        'display_author' => 'no',
        'limit' => 10,
        'before' => '',
        'after' => ''
    );

    function __construct($id_base = false, $name = '', $widget_options = array(), $control_options = array()) {
        $this->widget_description = __("New topics or topics with new replies.", "gd-bbpress-toolbox");
        $this->widget_name = 'GD bbPress Toolbox: '.__("New Posts", "gd-bbpress-toolbox");

        parent::__construct($this->widget_base, $this->widget_name, array(), array('width' => 500));
    }

    function form($instance) {
        $instance = wp_parse_args((array)$instance, $this->get_defaults());

        $_tabs = array(
            'global' => array('name' => __("Global", "gd-bbpress-toolbox"), 'include' => array('shared-global', 'shared-display', 'shared-cache')),
            'content' => array('name' => __("Content", "gd-bbpress-toolbox"), 'include' => array('newposts-content')),
            'extra' => array('name' => __("Extra", "gd-bbpress-toolbox"), 'include' => array('shared-wrapper'))
        );

        include(GDBBX_PATH.'forms/widgets/shared-loader.php');
    }

    function update($new_instance, $old_instance) {
        $instance = $old_instance;

        $instance['title'] = strip_tags(stripslashes($new_instance['title']));
        $instance['_display'] = strip_tags(stripslashes($new_instance['_display']));
        $instance['_cached'] = intval(strip_tags(stripslashes($new_instance['_cached'])));
        $instance['_class'] = strip_tags(stripslashes($new_instance['_class']));
        $instance['_tab'] = strip_tags(stripslashes($new_instance['_tab']));
        $instance['_hook'] = sanitize_key($new_instance['_hook']);

        $instance['period'] = strip_tags(stripslashes($new_instance['period']));
        $instance['scope'] = strip_tags(stripslashes($new_instance['scope']));
        $instance['limit'] = intval(strip_tags(stripslashes($new_instance['limit'])));
        $instance['display_date'] = strip_tags(stripslashes($new_instance['display_date']));
        $instance['display_author'] = strip_tags(stripslashes($new_instance['display_author']));

        if (current_user_can('unfiltered_html')) {
            $instance['before'] = $new_instance['before'];
            $instance['after'] = $new_instance['after'];
        } else {
            $instance['before'] = stripslashes(wp_filter_post_kses(addslashes($new_instance['before'])));
            $instance['after'] = stripslashes(wp_filter_post_kses(addslashes($new_instance['after'])));
        }

        return $instance;
    }

    function results($instance) {
        $instance = wp_parse_args((array)$instance, $this->get_defaults());

        $month = 0;
        $days = 0;
        $years = 0;
        $hours = 1;

        $scope = $instance['scope'];

        switch ($instance['period']) {
            case 'last_hour':
                $hours = 2;
                break;
            default:
            case 'last_day':
                $days = 1;
                break;
            case 'last_week':
                $days = 7;
                break;
            case 'last_fortnight':
                $days = 14;
                break;
            case 'last_month':
                $month = 1;
                break;
            case 'last_3months':
                $month = 3;
                break;
            case 'last_6months':
                $month = 6;
                break;
            case 'last_year':
                $years = 1;
                break;
        }

        $timestamp = mktime(date('H') - $hours, 0, 0, date('n') - $month, date('j') - $days, date('Y') - $years);

        switch ($scope) {
            case 'topic,reply':
                return gdbbx_get_new_posts($timestamp, 0, $instance['limit']);
            case 'topic':
                return gdbbx_get_new_posts_topics($timestamp, 0, $instance['limit']);
            case 'reply':
                return gdbbx_get_new_posts_replies($timestamp, 0, $instance['limit']);
        }
    }

    function render($results, $instance) {
        $instance = wp_parse_args((array)$instance, $this->get_defaults());

        gdbbx_widget_render_header($instance, 'bbf-newposts');

        if (empty($results)) {
            echo '<span class="bbf-no-topics">'.__("No topics found", "gd-bbpress-toolbox").'</span>';
        } else {
            echo '<ul>'.D4P_EOL;

            $show_date = isset($instance['display_date']) && $instance['display_date'] == 'yes';
            $show_author = isset($instance['display_author']) && $instance['display_author'] == 'yes';
            $path = gdbbx_get_template_part('gdbbx-widget-newposts.php');

            foreach ($results as $post) {
                include($path);
            }

            echo '</ul>'.D4P_EOL;
        }

        gdbbx_widget_render_footer($instance);
    }
}

?>

longtran295 on "How to delete post if view-count y"

$
0
0

I want automatically delete post if after a period of time, the post view count is lower than a given number but i don't know more about php So i hope someone can help me!

Here is what i figured out:

[ Moderator note: Code fixed, please wrap code in backticks or use the code button. ]

function del_post($post_id=0)
{
	$count = 0;
	$post_id = !$post_id ? get_the_ID() : $post_id;
	if ($post_id) {
		$meta_count_key = 'my_views_count';
		$count = get_post_meta($post_id, $meta_count_key, true);
		if ($count == '') {
			delete_post_meta($post_id, $meta_count_key);
			add_post_meta($post_id, $meta_count_key, '0');
		}

		$count = intval($count);
	}

		if ($count < 10) {
        $post_date = strtotime($post->start_date);
        if(((time() - $post_date) > (7 * 24 * 60 * 60))) {
        wp_delete_post($post->ID);
        }
		}
}

Hoopkjaz on "Categories meta box in admin panel - filter categories to only show 5 categories"

$
0
0

Hi,
I would like to filter the categories metabox in the admin panel and only show 5 categories. I have tried to find the query that gets the categories but I am not familiar enough with PHP and wordpress.

Below is a screen shot of the meta box that needs filtering.

Link to screen capture.

I have read a ton of blogs about removing the metabox and then replacing it with a custom one.
But isn't there a way to modify the default meta box query?

Thanks

admiralchip on "How to prevent double form submission?"

$
0
0

Hi,

I'm building a custom plugin that involves submitting data using a form. The form works quite well but it is susceptible to double submission. How can I prevent double form submission?

I used this. It disables the submit button but it prevents inserting of the values into the database table:

<form ... onsubmit="myButton.disabled = true; return true;">

How can I fix this?

Thanks in advance!

wpDavy on "Taxonomy custom fields"

$
0
0

Hi!

Firstly, sorry for my bad english.

I'm new here and I need to make sure my choice is good.

I add custom post type "books" in my wordpress installation
I want to add the publisher like a taxonomy and I want to add more information about publisher : link to the official website, the number of known best sellers and probably other in the future.

To add these information to my taxonomy, I found this :
taxonomy_add_form_fields
It does exactly what I want, but I don't found anything in codex.wordpress... I don't want to choose this solution if this hooks will be deprecated in the future WP versions...

What do you think ? Can I use it or not ?

Thanks.

sescpapa on "randomizing ONE post on homepage - the right way?"

$
0
0

First I had tried the get_posts tag and initially it worked.
But then, as I kept adding posts, I got more than one posts displayed.
At one point, I tried deleting the Loop, and using the get_posts tag by itself, and that solved my problem.
But after doing some reading, I got the impression that the wp_query is to be preferred. And eventually I got that working, too.
After doing some more reading, though, I now have the impression that the optimal way to do it is to use the pre_get_posts function.
Is this impression correct?
Is the pre_get_posts function the best way to randomize or elsewise modify the post/posts being displayed on the homepage of a website, while wp_query and get_posts are preferrable when dealing with individual subpages, such as categories etc.?
And is wp_query indeed better than get_posts for the latter purpose?
And, furthermore, is query_posts something I shouldn't even bother reading about?
Finally and most importantly, is my pre_get_posts solution correct?
I wrote this in my functions file:

function blablabla_pre_get_posts( $query ) {
	if( $query->is_main_query() && $query->is_home() ) {
		$query->set( 'orderby', 'RAND' );
		$query->set( 'posts_per_page', '1' );
	}
}
add_action( 'pre_get_posts', 'blablabla_pre_get_posts' );

and this in both my index.php and my home.php files:

<div class="inner">

<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
<h2><?php the_content(); ?></h2>
<footer>
<ul class="buttons vertical">
<li class="button fit scrolly">
<?php the_category(); ?>
</li>
</ul>
</footer>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e( 'Looks like there are no posts...' ); ?></p>
<?php endif; ?>
</div>

For one thing, I'm not sure if the wp_reset_postdata line is necessary.
And secondly, I'm not really sure it's working because so far, (I have tested it about five times, on different browsers, and by deleting history), I get my most recent post, which might be random, but might just as well not.
What do you wp-masters out there think?


brianpadraig on "Multisite Clone Duplicator -- Change Posts/Pages Authors"

$
0
0

I am trying to hack Multisite Clone Duplicator ( https://wordpress.org/plugins/multisite-clone-duplicator/ ) to automatically change the author of all the posts and pages on the duplicated site to the user that is duplicating them (I already used user-role-editor to make it so the users I want can duplicate certain pages)

Problem is I'm not quite sure what I'm doing here. So I'm trying to add the wp_update_post function, but is there a way to make it change all posts/pages, or do I have to list each post ID? and how do I hook it in so that it happens right as the page is duplicated? and do I do something like post author => $current_user to make it change to the person who does the duplication?

Am I anywhere near doing something that makes sense?

thanks for the help, I'm imagining this would be an easy addition for someone who is more well versed in coding and such, so any help would be greatly appreciated.

SteelGrimpeur on "Conditional output depending on two field values"

$
0
0

Hi all,

Non-coder needs plugin solution for what would seem a very simple thing.

Need to output price/time info for delivery between 6 departures and 6 arrival destinations chosen in 2 dropdown lists. It's not a calculation, just a grid. Here's the logic :

If dropdown-list1 = "NEWYORK"
and dropdown-list2 = "HONGKONG"
then output = "Price/Time"

Thanks in advance for any help.

VikrantNikam on "Get Terms Related to Terms and Categories"

$
0
0

I have custom post types as 'article', 'report', 'white-paper', 'publication', 'video'.

I have custom taxonomies as 'industries', 'services', 'writer', 'person', 'topic'.

I have a category as 'thought-leadership'.

I want to get all terms related to the particular taxonomy from all posts under any of the above post types onto the template page for 'thought-leadership'.
i.e., I want to show 5 select boxes on the template page for 'thought-leadership' - 1 select box for each taxonomy. Each select box should list down terms from posts for any of the above mentioned post types and marked in the category 'thought-leadership'.

e.g:
If I have a post from article post type and I have a term called 'Automobile' for the 'industries' taxonomy.
Then I add a post from report post type and I have a term called 'Energy' for the 'industries' taxonomy.

The the template page for category 'thought-leadership' should have 'Automobile' and 'Energy' in the select box for 'industries' taxonomy.

Based on the term selected from the select box, the posts lists should get updated.

Would be great if someone could give me a query for this and tell me how to refresh the page and display the posts according to the term selected.

leondemeij on "Estimated reading time search filter?"

$
0
0

Hi guys, I'm new here, so first of all: Hello Wordpress-users!

I have a real urgent question, and it's been driving me crazy.
I'm working on a project for a client, who wants an estimated reading time to be displayed per post. After some time researching several plugins I found that the plugin 'Post Reading Time' does the trick.

However, the website is supposed to get a 'filterable' searchform, where users can search/filter on categorie (i.e. thriller, drama etc.), reading time, author etc. etc.

I can't get my head around how to manage it that users can filter posts on category, estimated reading time and author. Do you guys have any tips for me on how to set this up?

Thanks a bunch!

hityr5yr on "How to popup a message to users after downloading my plugin?"

$
0
0

Hi all,

Could anyone suggest me how to make my plugin so that users get message with some instructions after downloading or updating it?

Thank you!

Viewing all 8245 articles
Browse latest View live




Latest Images