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

wpfan1000 on "Using add_action( 'admin_head') vs admin_enqueue_scripts"

$
0
0

Hi,

I would like to add some css styling to the admin menus, and I see 2 ways to do it:

Echoing styles into the html:

function my_custom_admin_head() {
	echo '<style>[for="wp_welcome_panel-hide"] {display: none !important;}</style>';
}
add_action( 'admin_head', 'my_custom_admin_head' );

or adding a css sheet:

function load_custom_wp_admin_style() {
        wp_register_style( 'custom_wp_admin_css', get_template_directory_uri() . '/admin-style.css', false, '1.0.0' );
        wp_enqueue_style( 'custom_wp_admin_css' );
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );

I am not sure if one has advantages over the other, any advice would be much appreciated.

Thanks in advance...


Jasnick on "Adding 'text' fields to widget"

$
0
0

I am creating a widget plugin to make it easier for an editor to add data. It has a title,3 text fields and a textarea.
In Admin this displays as intended but on the front end it doesn't.
I know this is because I need to properly ID the text fields.

// Check values
if( $instance) {
     $title = esc_attr($instance['title']);
     $text = esc_attr($instance['text']);
     $text = esc_attr($instance['text']);
     $text = esc_attr($instance['text']);
     $textarea = esc_textarea($instance['textarea']);
} else {
     $title = '';
     $text = '';
     $textarea = '';
}

I have changed <?php _e...> to the correct name for each text field but I need to know where else to make changes so it displays correctly at the front end.
Thank you!

MrConn on "How to get a sticky facebook-like bar?"

$
0
0

Hi,
Can anyone help me getting a sticky facebook-like/share bar on bottom?
I love the solution on this blog (Decrease screen size to see on PC)

(Sorry for doublepost. Wrong forum at first.)

kristina87 on "multi layer search"

$
0
0

Hello,

I'm wondering if someone could give some guidance..perhaps recommend a plugin.

I need a multi layer search function for my site.

I have pages (with posts) that are restricted to certain groups - this content has to be searchable within this particular restricted category

Then I have pages & posts that are public, and the public search should not pull the restricted pages in results. I achieved this using the following code:

[ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

add_filter( 'pre_get_posts', 'ja_search_filter' );
/**
 * Exclude category 7 from search results.
 *
 * @since ?.?.?
 * @author Jared Atchison
 * @link https://gist.github.com/1300302
 *
 * @param WP_Query $query Existing query object
 * @return WP_Query Amended query object
 */
function ja_search_filter( $query ) {

	if ( $query->is_search && !is_admin() )
		$query->set( 'cat','-100,-106' );

	return $query;

}

However this prevents the private group to be able to search for the restricted content as well.

Is there anyway to solve this? Comments need to be included in both searches as well.

Thank you in advance!

noormohammed on "How to hide audio url"

$
0
0

Can you please help me how to encode or hide the audio URL for viewing in the source code from the browser.

I like screenshots on "How to rename the "Published on" text in the post edit publish metabox"

rrfranco92 on "Adding a custom taxonomy to a SQL Query"

$
0
0

Hello Guys,

I'm trying to implement a new search option in store locator plugin.

I needed to add a custom taxonomy and I was successful with it but now I need it to work with the search system.

I have this SQL Query, which the plugin dev pointed me at, but I don't know much about SQL so I'm asking for your help.

$cat_filter = "INNER JOIN $wpdb->term_relationships AS term_rel ON posts.ID = term_rel.object_id
                               INNER JOIN $wpdb->term_taxonomy AS term_tax ON term_rel.term_taxonomy_id = term_tax.term_taxonomy_id
                                      AND term_tax.taxonomy = 'wpsl_store_category'
                                      AND term_tax.term_id = %d";

Here I need to add the option of also search by my new custom taxonomy, which is called wpsl_custom_category.

I already tried adding by duplicating
AND term_tax.taxonomy = 'wpsl_custom_category'
but then neither of the search fields work.

Can you please help me with this?

cyberlp23 on "Prevent posting when no category is selected"

$
0
0

Hello,

I'm trying to trigger an action if, when a user tries to publish a post, no category is selected:
- It could either be just an alert message (and the post is still published);
- Or actually alter message + preventing the post from being published.

Searching on this forum, I've found the code:

jQuery('#submitdiv').on('click','#publish',function(e){
            var $checked = jQuery('#category-all li input:checked');
            if ( $checked.length <= 0 ) { //Checks if cat is selected
            alert("Please Select atleast one category");
            return false;
            }else{ //Else continue
                return true;
            }
            });

But I have no idea where to put it.

Thanks!


brokendisk on "Get most recent post with custom taxonomy then filter by same"

$
0
0

I've created a custom taxonomy called 'issue'. Posts can be assigned an issue such as 'Magic' or 'Rainbow' or whatever. On the index page I'm doing something like this:

<?
// get latest post with an issue id
// set that issue id to $issue
$issue = 'magic';
$issue_query = new WP_Query('issue=' . $issue . '&showposts=4');

while ($issue_query->have_posts()) : $issue_query->the_post();
?>

What I'd like is explained in the commented lines. Get latest post that has an issue assigned to it and set $issue to it. The idea is that the issue assigned to posts will change maybe once every few months, and I'd like the displayed posts to update automatically when it does.

rosyb on "displaying attachment custom fields"

$
0
0

We have added custom fields to the media library, and this is working well, but the issue is getting the data back out in a form that suits us.

By altering the template for the attachment page we can display the fields along with the image. See here: example when clicking on the image of the rose at the bottom.

However, what I am really wanting is something more like this example where when you mouseover an image you get the data shown.

I don't mind if it is a popup box, or a drop-down caption box below the image, but I just want to find a way to display this data when needed without it always being there or needing to open a separate window/tab!!

Many thanks in advance for any help received, as i am sure there is a logical solution but I just can't see it!

maspegren on "When init runs compared to the_content filter"

$
0
0

I'm developing a plugin that looks for parameters in the URL, then will call a filter for the_content to do a search/replace based on the parameters. Cookies are set so the user can travel throughout the site and still see the search/replace. I have all of the code working correctly, upon the first page load the cookies are set but the search/replace isn't done. If I refresh the page then the search/replace is completed. I'm thinking the search/replace is done first and failing since there are no cookies, THEN the cookies are being set. That's why it is successful the second page load. I know the search/replace function is getting called since I can echo on first page load, but the cookies won't print even though they are displayed in the developer tools. This tells me the cookies don't exist when the search/replace is being ran, but they exist once the whole site is loaded.

Anyway, I'm using add_action('init', my_function) for the cookies and add_filter('the_content', my_other_function) for the search/replace. Can anyone tell me if init is called after the filter? If so, what should I use instead? Thank you!

Riccardo79 on "Subscriber profile page"

$
0
0

Hello everyone
I'm Riccardo and I'm new to this forum (and I don't know if this is the correct section).
I need to create a platform on my site in which every user (which has role "Subscriber") can put a description of himself, and add an arbitrary number of pictures or video.
So the site will have a profile page for every user.
Is there an easy way to do this, since Subscriber users have not a profile page?

Thanks in advance,
Riccardo

lonestargemstones.com on "Add WooCommerce variable product attributes to form"

$
0
0

I'm writing a plugin that allows customers to request additional information via an email form about a woocommerce product. I'm able to pull in the Simple product information, but when I try to pull the variation name and SKU on a variable product, it still only brings back the parent product information, or the white screen of death. Either way, not a favorable outcome. At this point I'd settle for the parent product with additional variable fields for the attributes. Any help is appreciated.

Here's what I have so far:

function lsg_before_info_req_button() {
global $product;

if( $product->is_type( 'simple' ) ) {
if( class_exists( 'lsg_info_req' ) ) {
echo "<input type=\"hidden\" name=\"info_request\" value=\"". esc_attr( $product->id ) . "\" />";
echo "<button type=\"submit\" class=\"info_req_button button alt\">" . apply_filters('info_req_text', __( 'Email for More Information', 'woocommerce' ), $product->product_type) . "</button>";}
else {
echo "<button type=\"submit\" onclick='this.form.action=\"" . add_query_arg('product_id', $product->id, get_permalink( get_option('lsg_info_req_page_id') )) . "\";' class=\"info_req_button button alt\">" . apply_filters('info_req_text', __( 'Email for More Information', 'woocommerce' ), $product->product_type) . "</button>";}}
elseif( $product->is_type( 'variable' ) ) {
echo "<div class=\"single_variation_wrap\" style=\"display:none;\">";
echo "<div class=\"single_variation\"></div>";
echo "<div class=\"variations_button\">";
echo "<input type=\"hidden\" name=\"variation_id\" value=\"\" />";
woocommerce_quantity_input();
if( class_exists( 'lsg_info_req' ) ) {
echo "<button type=\"submit\" class=\"info_req_button button alt\">" . apply_filters('info_req_text', __( 'Email for More Information', 'lsg' ), $product->product_type) . "</button>";}
else {
echo "<button type=\"submit\" onclick='this.form.action=\"" . add_query_arg('variation_id', $variation->id, get_permalink( get_option('lsg_info_req_page_id') )) . "\";' class=\"info_req_button button alt\">" . apply_filters('info_req_text', __( 'Email for More Information', 'lsg' ), $product->product_type) . "</button>";}
echo "<input type=\"hidden\" name=\"add-to-quote\" value=\"" . $variation->id . "\" />";
echo "<input type=\"hidden\" name=\"variation_id\" value=\"" . esc_attr( $post->ID ) . "\" />";

Luke Watts on "Can I use "options" or "theme_mod" values from WP_Customizer in other functions?"

$
0
0

I've added a setting in the Customizer which is (supposed) to allow users to add css class names to the body tag.

So then in another function I want to add a filter of the body_class hook to add the classnames entered.

The following doesn't seem to work:

function custom_body_class_filter($classse)
{
    $classes[] = get_option('custom_body_classes);

    return $classes;
}
add_filter('body_classes', 'custom_body_classes');

Do I need to call the options globally within any other function? Such as:

global $wp_options; // or $wp_cusomize or something else?

Thanks.

dzung on "How can I add a Custom Dashboard for registered users?"

$
0
0

Hi all

I'm building a restaurant booking site:
- On the front end, I will create a page for each restaurant - it will have a form for submitting booking requests.
- On the back end I need to create a custom dashboard for registered users.

So when user submit a booking request, the booking will be added to his booking history section in his profile page like this one: link image It's from a theme for tour and hotel booking - I will need to change Tour to Restaurant.

I hope to find existing solution/plugin or tips/documents/guide on creating one for myself. Please help!


ghorbani77 on "hack in my web site"

$
0
0

hello dear friends .
i have a web site with wordpress 4.3.1 , and i have enable password for wp-admin folder in host ,
i have install limit login attempt plugin And captcha plugin .

i have more attack to login my wordpress , i`d block any ip address that who give 3 unvalid password ,
is there any bot for brought forth attack that can undrestand captcha code ???

its importatnt attack , please help me , thanks
my web site address is :
http://tablokar.ir

eatechniques on "Add hover button effect in menu"

$
0
0

I am new to this.
Where can I add CSS code for my header menu?
I have installed the Custom CSS plugin, so I guess I can use that?

I have a theme called Tesseract.
I already have a header hovered link color effect, but what I want is a hover effect that covers the menu link like a big box that fills the whole link from top to buttom of the header/menu.

I have tried this code in the Custom CSS plugin to test, but it only sourrounds my link with a tiny box:

menu {font-size: 12px; background: #00ffff; padding: 1px;}
menu a{ color: ff0000; background: #fff; }
menu a:hover { color: #000; background: #00ff00; }

It also does not overwrite the css color from the settings I already have, which for me is okay - but thought maybe that could be relevent for the support here.

Any ideas on how to code this better?

gkovar on "Redirect After Login (Understanding Filters & Best Practices)"

$
0
0

I'm trying to create a redirect when a user logins. I've read a bit on login_redirect and I'm reasonably confident I understand how it works.

I guess my confusion is on how can I figure out what filters are being applied and in what order? Is my filter falling before another filter that is changing it back?

My code is below...and it currently resides in my functions.php file in my template dir. What's best-practice on something like this as it's not really template related?

//Change page after login
function default_page_users () {
	return 'post-new.php?post_type=appearances';
}
add_filter('login_redirect', 'default_page_users');

gugmi01 on "Help needed for Chicago map plugin"

$
0
0

Hey there,

So I will be upfront right away that I have very little to no experience in coding especially with WordPress. However, I was wondering if anyone could be of help with a project I am working on.

To give a bit of back story- I live in Chicago, work as a photographer and recently went to all 77 neighborhoods of Chicago to take photos of people from every neighborhood.

Now, on a certain page on my website: http://mikegugliuzza.com/chicagomap/ I would like to somehow organize and showcase the entire project.

I have made a map of Chicago using Illustrator and linked it to this plugin: http://codecanyon.net/item/mapsvg-interactive-vector-maps-and-floorplans/2547255

Currently and at default whenever a neighborhood is clicked on it will bring the user to a different page on the website, however, I would prefer that the act of clicking on a neighborhood would trigger some kind of photo frame/ lightbox on the same page as the map to display the image.

I'm assuming because the plugin has a section for custom coding within each individual region (Example of layout: http://tinypic.com/r/13zzux3/8) there could be a simple html code for a click to command an action on another plugin found on the page- though because I have no wordpress experience, I am not even sure what to google to find such a code or plugin.

I would definitely appreciate any help or suggestions.

Thanks very much!
Mike

mxm.k.marquette on "Hi i want to exclude a category"

$
0
0

hi i just setup a random post thingy in my wordpress

<?php
add_action('init','random_add_rewrite');
function random_add_rewrite() {
global $wp;
$wp->add_query_var('random');
add_rewrite_rule('random/?$', 'index.php?random=1', 'top');
}
add_action('template_redirect','random_template');
function random_template() {
if (get_query_var('random') == 1) {
$posts = get_posts('post_type=post&orderby=rand&numberposts=1');
foreach($posts as $post) {
$link = get_permalink($post);
}
wp_redirect($link,307);
exit;
}
}
?>

and i want to exclude a category from the random link thingy is that possible ? and how to do it

Viewing all 8245 articles
Browse latest View live




Latest Images