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

jeltoesolnce on "Can I activate|deactivate plugins from console or external code?"

$
0
0

Hello, I want deactivate and activate one plugin from console, can I do that?


Usman Ali on "Saving options on paginated paged"

$
0
0

Hi,

Can anyone tell me how can I save options for the fields on paginated pages I mean if some options are changed and saved on one page then other options on other pages don't get disturbed.

I created a pagination in my plugin but when I save options for example on page 2 the options on page one get reset automatically and I want to fix this.

Thanks

Craig Ralston on "Using get_plugins() to pass plugin file path to is_active_plugin()"

$
0
0

A rundown of my issue:
I am working with a file that lives in the root along with wp-config.php and such. I am requiring wp-admin/includes/plugin.php and wp-load.php and my goal is to retrieve plugin data quickly and easily from a site. I have been mostly successful in my attempts, so far but have hit a small bump that I am hoping someone can assist with. My initial function uses the array get_plugins() and I am using data from that but I also need to check which plugins are active/inactive. Looking at the Codex, is_active_plugin($plugin) seems to do exactly what I want - Check if the plugin is active. I don't want to specify a file path, obviously, because I am checking all plugins, so I've been trying to use the data from get_plugins() to pass the file path to is_active_plugin but nothing has been working. If I do a var_dump(get_plugins();), the path I need is the key but if I try to use the key, the first plugin is just repeated every time. I suspect this is due to that fact that the get_plugins() array has another array for each plugin. Every plugin appears as inactive.

function ws_plugin_list() {
    $all_plugins = get_plugins();
    echo '<ul style="list-style-type: none;">';
    foreach ($all_plugins as $plugin_item) { ?>
        <li>
            <a href="<?php echo $plugin_item['PluginURI']; ?>">
                     <?php echo $plugin_item['Title']; ?>
            </a>
        </li>
        <li>
            Version: <?php echo $plugin_item['Version']; ?><br />
            This plugin is currently <?php if (is_plugin_active(key($plugin_item))) { echo 'active'; } else { echo 'inactive'; } ?>
        </li>
        <br />
<?php }
    echo '</ul>';
}

Here is the var_dump(get_plugins()); - As you can see, something like the akismet/akismet.php is what I am trying to collect and pass to is_plugin_active().

array(3) { ["akismet/akismet.php"]=> array(11) { ["Name"]=> string(7) "Akismet" ["PluginURI"]=> string(31) "http://akismet.com/?return=true" ["Version"]=> string(5) "2.5.9" ["Description"]=> string(433) "Used by millions, Akismet is quite possibly the best way in the world to protect your blog from comment and trackback spam. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) Sign up for an Akismet API key, and 3) Go to your Akismet configuration page, and save your API key." ["Author"]=> string(10) "Automattic" ["AuthorURI"]=> string(40) "http://automattic.com/wordpress-plugins/" ["TextDomain"]=> string(0) "" ["DomainPath"]=> string(0) "" ["Network"]=> bool(false) ["Title"]=> string(7) "Akismet" ["AuthorName"]=> string(10) "Automattic" }

I apologize if this is not the correct place to ask my question.

KimTasker on "plugin admin page hook has no action ?"

$
0
0

Hi all,

I just fell upon this issue while developping a new plugin. It's the first time I see this :

when I send a form I have on one of my admin pages for this plugin, I get this error : Cannot load my-plugin-page , my-plugin-page being the name of the page I'm trying access, which is actually the same where the form was sent from.

After some investigation it appears that if ( has_action($hook) ) in the get_plugin_page_hook function (in wp-admin/includes/plugin.php) returns false.

I'm rather sceptical as I can properly access the page from my admin menu link

After further testing, I discovered the problem may be caused by an element in my form : <input type="hidden" name="post_type" value="my-value" />
as I no longer have the issue after removing it.
So I guess my problem can be considered 'resolved' as I don't need this data anyway...

But, I'd really like to understand
Why would a $_POST element named 'post_type' break the access to my plugin admin page ?
What does one thing have to do with the other ?
Is this normal behavior ?

If someone could give me insight here, it would be greatly appreciated, thank you ;)

Moasy on "Custom post type is display a separator"

$
0
0

Hi, I just created a custom post type (based on the Bones starter theme template). Everything is ok except that the admin tab printed add a separator and I don't know how to search for deleting it.
Here's my custom post code:

// let's create the function for the custom type
function custom_post_example() {
	// creating (registering) the custom type
	register_post_type( 'custom_type', /* (http://codex.wordpress.org/Function_Reference/register_post_type) */
		// let's now add all the options for this post type
		array( 'labels' => array(
			'name' => __( 'Prodotti', 'ali' ), /* This is the Title of the Group */
			'singular_name' => __( 'Prodotto', 'ali' ), /* This is the individual type */
			'all_items' => __( 'Tutti i prodotti', 'ali' ), /* the all items menu item */
			'add_new' => __( 'Aggiungi nuovo', 'ali' ), /* The add new menu item */
			'add_new_item' => __( 'Aggiungi un nuovo prodotto', 'ali' ), /* Add New Display Title */
			'edit' => __( 'Modifica', 'ali' ), /* Edit Dialog */
			'edit_item' => __( 'Modifica prodotto', 'ali' ), /* Edit Display Title */
			'new_item' => __( 'Nuovo prodotto', 'ali' ), /* New Display Title */
			'view_item' => __( 'Visualizza prodotto', 'ali' ), /* View Display Title */
			'search_items' => __( 'Cerca prodotto', 'ali' ), /* Search Custom Type Title */
			'not_found' =>  __( 'Nothing found in the Database.', 'ali' ), /* This displays if there are no entries yet */
			'not_found_in_trash' => __( 'Nothing found in Trash', 'ali' ), /* This displays if there is nothing in the trash */
			'parent_item_colon' => ''
			), /* end of arrays */
			'description' => __( 'This is the example custom post type', 'ali' ), /* Custom Type Description */
			'public' => true,
			'publicly_queryable' => true,
			'exclude_from_search' => false,
			'show_ui' => true,
			'query_var' => true,
			'menu_position' => 3, /* this is what order you want it to appear in on the left hand side menu */
			'menu_icon' => 'dashicons-list-view',
			'rewrite'	=> array( 'slug' => 'prodotto', 'with_front' => false ), /* you can specify its url slug */
			'has_archive' => 'custom_type', /* you can rename the slug here */
			'capability_type' => 'post',
			'hierarchical' => false,
			'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'revisions', 'sticky')
		) /* end of options */
	); /* end of register post type */
}

And here you can see how it display the additional separator.

Thank you for your help

joeguilmette on "Add image size to div.wp-caption"

$
0
0

WP is nice enough to add the image size as a class to the img element. however, the parent a and div.wp-caption do not have such classes. As such, one is unable to position or style images differently depending on their size.

I've search high and low and am unable to find a path. Perhaps a filter? Any help would be appreciated!

fox87 on "why my javascript stop working, when include the code in the page"

gpspake on "Upload files to a plugin directory from plugin options."

$
0
0

I'm working on a plugin that requires a certificate to be placed on the server. Right now, users have to manually add the certificate to the plugin directory which requires ftp access.

I'd prefer to give users a way to upload the file directly to the server from the plugin options. I assume this is relatively easy, right?


gstricklind on "Shortcode content appearing before p tag"

$
0
0

I'm working on a simple column short code plugin. The first paragraph within a short code isn't wrapped in the p tag, but the following paragraph is. I've read this article about problems with wp_autop, and searched google but I can't seem to figure out a solution or why this is happening.

[one_half]paragraph

paragraph[/one_half]
[one_half_last]paragraph

paragraph[/one_half_last]

Without any modification with wp_autop or anything, the html output looks like this:

<div class="one_half">
  paragraph
  <p></p>
  <p>paragraph</p>
</div>
<div class="one_half last">
  paragraph
  <p></p>
  <p>paragraph</p>
</div>

How can I get the first paragraph to be wrapped inside that p tag with proper coding?

Timothy Jacobs on "WP Metadata User Query on non-existent fields"

$
0
0

Hi all,

I am using the WP_User_Query class, and the meta search ( meta_key, meta_value, meta_compare ) capabilities.

I am trying to do a search for all users who do not have a certain meta_key set to true. However, if the metadata does not exist for the user, then WP_User_Query doesn't return that user, despite the fact that I am using != as the comparison.

Here is my code, any thoughts?

$query = new WP_User_Query( array(
		  'role'         => 'some_slug,
		  'meta_key'     => 'some_sort_of_meta_key',
		  'meta_value'   => 1,
		  'meta_compare' => "!=",
		  'number'       => 25,
		  'offset'       => $user_offset
		) );
		$users = $query->get_results();

Thanks!

svibor on "what is meaning of this code?"

$
0
0

hello everybody!

I have a question about this code that I found in header.php:

<?php cryout_seo_hook(); ?>

It is right beneath <head>.

Can someone tell me where does this code came from? Is it some plugin that put it there, or it should be there by default?

It doesn't show in source code, but it putting <title>. But, the text that it put in <title> is no good for me, and I would like to change it. So I'm wondering could I delete this code and manually write <title> tag?

Any help or advice would be priceless!

Thank you.

trink79 on "add youtube video title to oembed generated iframe"

$
0
0

For web accessibility reasons I need to have a title on the iframe generated by oembed for youtube videos. i found a hack that lets you specify the title but that makes it the same for all videos. is there a way to have oembed add the video title to the iframe as the title attribute?

the current code generated:
<iframe width="604" height="340" src="http://www.youtube.com/embed/VLK9ckgeXAc?feature=oembed" frameborder="0" allowfullscreen=""></iframe>

the desired code:
<iframe width="604" height="340" title="title of video" src="http://www.youtube.com/embed/VLK9ckgeXAc?feature=oembed" frameborder="0" allowfullscreen=""></iframe>

Victor on "Dynamically change [site_url] depending on current URL"

$
0
0

Hi,

To provide some background, I want to work on 2 domains:
- live site, say - example.com,
- admin domain, say admin.example.com

The origin site is admin.example.com,
and example.com is the live site
(example.com synchronizes files periodically from admin.example.com)

So the WP option for the site URL is x.com.

I would like some help on the following:
- when accessing the site with admin.example.com URL,
I want the site to dynamically change links to comply with being on the admin.example.com site.

Here's an example:
I go to example.com - I already have all links relative to example.com.
I go to admin.example.com, I want all blog URLs to link up relative to admin.example.com, even tough the config site URL is example.com.

admin.example.com is a hypothetical example, as I need to change hosts
file entries and target example.com to admin.example.com IP for it to work.

Do I have to do something more than change the site/admin URL using
add_filter('site_url', 'custom_site_url') in the functions.php file?
Does this affect any login cookies on the admin side?

So besides changing the site_url with the filter, what should I do additionally in order for the site and admin to work with admin.example.com without changing the site URL config wide?

Thanks!

epd on "How to add jQuery smooth scroll"

$
0
0

Hello,
i need to add jQuery smooth scroll for scrolling my pages , i want make it without WP plug in.

can someone tell how can do it?

thank you
regards

ivarlarsen on "How to put the woocommerce cart up into the header in the theme twenty twelve"

$
0
0

How do I get the shopping cart icon into the header of my Twenty Twelve theme?

Here is a depiction of what I mean http://postimg.org/image/wmyoo4ck9/

Any help is appreciated. Hope you can help me guys

Thanks in advance :D


locph on "Wordpress deleted un-expired transient after post editing"

$
0
0

I set up some transients (expired in 1 day) to save query results on a custom post type (e.g Class). Then, if I go to update any kind of post or user profile, my transients was cleared.

My question is how can I prevent that behavior? I just want to clear them if and only if I've updated a Class post (using the hook publish_post) or they was expired.

Thanks for your help.

jeyreem on "Exclude ID next_post / prev_post"

$
0
0

Hi everyone,

I've a little problem and i really need you. I dev a website, and i want to exclude an ID (only use for the home) in next_post/prev_post, i search on the web and i've found:
<?php previous_post_link('« %link', '%title', FALSE, 'IDofCat'); ?>
But that's don't work in my case, i make a cat only for this post but still doesn't work. And i prefer to exclude it only with ID of post if it's possible. I need you guys ! My code here:

<?php while (have_posts()) : the_post(); ?>
<div class="container" id="singlePort">  

    <div class="row content">
        <div class="col-md-1 col-sm-1"></div>
        <div class="col-md-10 col-sm-10">
            <div class="illuPort alignleft">
                <img src="<?php the_field('illustration'); ?>" alt="<?php the_field('txt_alt'); ?>" class="img-responsive illustration" />
            </div>
            <div class="contentSinglePort">
                <p class="topSinglePort"><span id="sector"><i class="fa fa-dot-circle-o"></i> <?php the_field('secteur'); ?></span><br/><a style="color: #4885d9;" href="<?php the_field('link_site'); ?>" TARGET='_blank'><i class="fa fa-link"></i> <?php the_field('link_site'); ?></a><p>
                <?php the_content(); ?>

            </div>
        </div>
    </div><!--/.row-->
    <div class="row">
        <p id="navigation">
            <span id="previous"><?php previous_post('<i class="fa fa-angle-left fa-2x"></i> %', 'Projet précédent : ', 'yes', FALSE, '26'); ?></span>
            <br class="hidden-lg hidden-md hidden-sm"/>
            <span id="next"><?php next_post('<i class="fa fa-angle-right fa-2x"></i>%', 'Projet suivant : ', 'yes', FALSE, '26'); ?></span>
        </p>
    </div>
    <?php endwhile; // end of the loop. ?>

PS: it's a custom post type so i don't know if you really care about that.

Best regards, have a nice day,
Jeyreem

jnrbrle on "no url in onepage template"

$
0
0

Hi, I've made a simple onepage website on reduxframework, with only index page divided into sections. My nav is hard coded into the page. I'm not good with ajax, so this was the fastest solution for me. However I've encountered with a problem. I dont know how to display urls of post in my theme. Here is an example

http://dusanbalaz.slovenskagaleria.sk/

Portfolios on this page are made via plugin called Ajax portoflio. I can give-send everything else from this theme, except for that plugin, which is payed.

I've search for a solution on google, on the best thing I could find was html pushstate. However, every tutorial was for ajax based websites, which isn't the case for this site, so it didnt work for me.. Any ideas??

Thx. Jan

rick111 on "Direct registered users to post page"

$
0
0

It has been probably answered before but my registered users (Subscribe2) go to their profile page when they log on. I want them to go to the post page. I can use pluginception for the hook code as I do not want to modify functions because it will go away after an upgrade.

nat@cry on "WooCommerce Different text for add to cart depending on product category"

$
0
0

Right so the scene!

Would like a different text to appear on the add to cart button.

If is in category 'Donation' use custom text of donation
But for the rest of the products display other custom text "Add"

This is my code so far,

add_filter( 'add_to_cart_text', 'woo_custom_cart_button_text' );                                // < 2.1
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' );    // 2.1 +

function woo_custom_cart_button_text() {
	if(is_product_category('Donation')) {
	return __('Donate', 'woocommerce' );
  } else {
	  return __('Add', 'woocommerce' );
  }
}
Viewing all 8245 articles
Browse latest View live




Latest Images