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

Dudo on "Can't output do_settings_sections . Can't understand why"

$
0
0

I've this code:

/* Hook to admin_menu the yasr_add_pages function above */
add_action('admin_menu', 'yasr_add_pages');

function yasr_add_pages() {

    //Add Settings Page
    add_options_page(
                    'Yet Another Stars Rating: Settings',               //Page Title
                    __('Yet Another Stars Rating: Settings', 'yasr'),   //Menu Title
                    'manage_options',                                   //capablity
                    'yasr_settings_page',                               //menu slug
                    'yasr_settings_page_content'                        //The function to be called to output the content for this page.
                    ); 

}

/* Settings Page Content */
function yasr_settings_page_content() {
    if ( !current_user_can( 'manage_options' ) )  {
        wp_die( __( 'You do not have sufficient permissions to access this page.', 'yasr' ) );
    }
    include (YASR_ABSOLUTE_PATH . '/yasr-settings-page.php');

} //End yasr_settings_page_content

and, this is the content in yasr-settings-page:

<div class="wrap">
    <h2>Settings API Demo</h2>
    <form action="options.php" method="post">
        <?php
            settings_fields( 'yasr_multi_form' );
            do_settings_sections( 'yasr_settings_page' );
            submit_button( 'Salva' );
        ?>
    </form>
</div>

<?php

add_action( 'admin_init', 'yasr_multi_form_init' );

function yasr_multi_form_init() {
    register_setting (
                'yasr_multi_form', // A settings group name. Must exist prior to the register_setting call. This must match the group name in settings_fields()
                'yasr_multi_form_data' //The name of an option to sanitize and save.
    );

add_settings_section( 'yasr_section_id', 'Gestione Multi Set', 'yasr_section_callback', 'yasr_settings_page' );
add_settings_field( 'yasr_field_name_id', 'Nome Set', 'yasr_nome_callback', 'yasr_settings_page', 'yasr_section_id' );
}

function yasr_section_callback() {
    echo "Descrizione sezione";
}

function yasr_nome_callback() {
    $option = get_option( 'yasr_multi_form_data' );
    $name = esc_attr( $option['name'] );
    echo "<input type='text' name='yasr_multi_form_data[name]' value='' />";
}

The settings page output settings_field function (I can see the input type hidden on my source) and the submit button, but I can't render the do_settings_section and I really can't understand why. Any suggestions?


justbishop on "Adding Custom Action Link to Admin User List"

$
0
0

I'm trying to add a link to each user's author archive from the back end user list, in the list of links that appear for each user when their row is moused over. Here's the code I have so far:

function frontend_profile_action_link($actions, $user_object) {

	$actions['view profile'] = "<a class='view_frontend_profile' href='" . home_url( "/archives/author/" ) . get_the_author_meta( 'user_login' ) . "'>" . __( 'View Profile', 'frontend_profile' ) . "</a>";

	return $actions;

}

add_filter('user_row_actions', 'frontend_profile_action_link', 11, 2);

It works as far as displaying the link, but only to a point. It returns nothing after the "archives/author/" part of the URL, so every user's "View Profile" link ends up being http://www.mysite.com/archives/author/ when it should be http://www.mysite.com/archives/author/user_login

I'm not sure what I'm doing wrong. Is it my syntax in building the URL, or is get_the_author_meta not the function I need?

TIA :)

meschiany on "replacing core un-pluggable function"

$
0
0

hello,
I have about 3 million rows in postmeta and 60 thousands rows in posts.

when i checked for slow queries mysql, i notice that the core function meta_form() in wp-admin/include/template.php is taking about 6-7 seconds.

Original query:
SELECT meta_key
FROM wp_postmeta
GROUP BY meta_key
HAVING meta_key NOT LIKE '\_%'
ORDER BY meta_key
LIMIT 30;

I did some digging and I found a nice query to replace it:
SELECT DISTINCT meta_key
FROM wp_postmeta
WHERE meta_key NOT BETWEEN '_' AND '_z'
HAVING meta_key NOT LIKE '\_%';

how can i do it in my theme or somewhere without changing the core?
(no hook is available for that... as for i know...)
thanks

wendysahl on "Twenty Twelve Images Outside Article Border"

$
0
0

I'd like to apologize in advance, I posted this earlier on the themes and templates part of the forum but haven't received any answers. I'm not an expert but I feel like this origin of this problem may be in one of the .php files...basically, with a child theme, I am using Twenty Twelve. I have added a border around the article post content. Any images added as part of the content fall over the border and extend beyond it as if they are not loading as part of the post itself. If the text of the post is long enough to wrap around a left aligned small image then the border, since it does go around all of the text, also includes the image. I've tried placing text below the image in both the visual and text editor (with several
after the image in the text editor) and the post text still loads along side the image rather than beneath it. I know this isn't the forum to be walked through little things but if you could let me know if this is a known problem with a fix I would appreciate that. Thanks! **The site is for someone else and under construction so I am unable to provide a link to it. I've never had any trouble in Twenty Twelve before but I normally work with much larger images and no borders. Thank you.

bdeconinck on "Displaying recently published-to categories"

$
0
0

I haven't seen this discussed elsewhere, but I may have missed it. I'm sure someone has done this before.

My client has about 20 categories to which he actively assigns new posts. We want to display links to the three most recent categories in a menu in the header. That is, suppose your five most recent posts (in order from oldest to newest) are:

Post 1 -- Category A
Post 2 -- Category B
Post 3 -- Category C
Post 4 -- Category D
Post 5 -- Category D (again)

... we would want links to Categories D, C, and B to be displayed (no duplicate link for D).

Currently, my client assigns posts to only one category. I don't think he has any plans to change that, so I don't need to worry about the case when a post is assigned to several categories.

I've come up with a solution that will work involving a second loop, a post-counting counting array, and a bunch of if/else conditions to identify the categories I need. But that feels like using a chain saw for something better suited for a pocket knife. Is there a simple and lightweight way to do this?

Senff on "Call function on multiple actions"

$
0
0

I'm writing some function that needs to be executed every time something changes in the list of posts. So, whenever:
- a new post is published
- an existing post is edited
- an existing post is deleted

I was thinking to do it like this:

add_action('publish_post', myfunction());
add_action('post_updated', myfunction());
add_action('deleted_post', myfunction());

I think the second one is not even necessary (it's executed with publish_post anyways) but is there a better way to do this, instead of calling the function in various situations?

Is it possible to do something like this (not literally, but structure-wise)?

add_action( ('publish_post' OR 'post_updated' OR 'deleted_post') , myfunction() );

bmaggot on "Hook Woocommerce quantity with Gravity Forms data"

$
0
0

Hi,
I noticed that Gravity Forms quantity value does not subtract from actual item stock.
How do I hook WooCommerce quantity on checkout and change it to GF dropdown value?

shekhar1289@gmail.com on "How to add new menu item in buddypress member ppage"

$
0
0

Hi. I am creating a site using buddypress and also including shopping function using woocommerce.
I have done most of the work but stuck at one place.

I want to add "My Shopping" menu to buddypress member profile menu. Besides the activity button. It will be redirected to woocommerce my account page. I want to know how to do that? And also that "My Shopping" should not be seen when other member viewing someone's profile.

Please help me on this.


alirezaChimeh on "add playable link in download monitor"

$
0
0

Hi all
In download monitor plugin I create a new template for showing link of download. this page is : http://kheime133.ir/?p=63
How can I add a playable link that user can listen online to music and if like it, download it?

alirezaChimeh on "Get File URL from download monitor"

$
0
0

Hi
Download monitor plugin create a link for downloading a file.
how can I add File URL under that link ?

christopherstamper on "WooCommerce: Checking a wp-user field before allowing checkou"

$
0
0

I have a custom user field defined in WordPress, (Boolean)Authorized. I defined this field using another plugin (MemberPress) and it's accessible using the slug mepr_authorized.

I would like to check this field in the WooCommerce checkout process. If it's FALSE/0, then the user should not be able to complete the checkout process - and instead be presented with UI indicating as such. The field itself should not be displayed in an editable fashion.

Any ideas how I can do this?

One thought I had was a custom, non-editable but required field in WooCommerce, that I would automatically set via PHP (basically retrieve the user value and assign it). Is this feasible?

Any feedback is awesome. Thanks!

ricardobnews on "Problemas com Redirecionamento"

$
0
0

Ola boa Noite estou tendo problemas em 2 sites meus infelizmente recentemente não e 100% das vezes mais quando clico em algumas matérias tenho meu site redirecionado para um vídeo do youtube do Justin Bieber sem minha autorização meus leitores estão reclamando disso e muito chato e ta atrapalhando o desempenho! alguém sabe a causa disso ou como evitar? se existe algum plugin que proteja ou algo parecido por gentileza caso possam me ajudar agradecerei muito

joethall on "How to invoke a URL from a PHP plug-in?"

$
0
0

Need to create a PHP plug-in that can invoke a specific URL - http://.... - out on the internet. How can this be done?

Robodashy on "External database integration"

$
0
0

Before I go pastebin'ing a bucketload of code I'll give you the outline of the problem, then if y'all want the code I'll put it in a reply later - but here goes:

I'm developing a site for a client, pretty much just taking their existing .asp site and converting it to WP (while making it all nice and pretty).
Almost done, but now I'm stuck.

The custom search page they have references an external database they have, so what I've done is created a custom page hoping to implement this feature.

The custom page I've created works, right up until I get to the custom php/sql. If I have the file with just the code above and below the commented stuff that says it works the page renders fine, but no content. It's the stuff between that breaks it (basic code below):
'
<?php
/* BUNCH OF TEMPLATE GENERATING COMMENTS HERE */
get_header();

do_action( 'genesis_before_content_sidebar_wrap' );
genesis_markup( array(
'html5' => '<div %s>',
'xhtml' => '<div id="content-sidebar-wrap">',
'context' => 'content-sidebar-wrap',
) );

do_action( 'genesis_before_content' );
genesis_markup( array(
'html5' => '<main %s>',
'xhtml' => '<div id="content" class="hfeed">',
'context' => 'content',
) );

?>
/* CODE ABOVE WORKS *//* CODE ABOVE WORKS *//* CODE ABOVE WORKS */

/** This is where the problem lies **/

/* CODE BELOW WORKS *//* CODE BELOW WORKS *//* CODE BELOW WORKS */
<?php
genesis_markup( array(
'html5' => '</main>', //* end .content
'xhtml' => '</div>', //* end #content
) );
do_action( 'genesis_after_content' );

echo '</div>'; //* end .content-sidebar-wrap or #content-sidebar-wrap
do_action( 'genesis_after_content_sidebar_wrap' );

get_footer();
'

In the /** This is where the problem lies **/ section I have my includes to connect to the external database as well as a formating php file, shouldn't be any problems - then I have all the php/sql connection code that checks the database for ... data ... and then generates html based on the data received.

With this code included I get the white page of death. Can't even check to see if there are any errors being generated. I've checked for syntax errors but can't find any, so I'm assuming it has something to do with the way WP restricts access to outside sources (or just the way WP restricts stuff in general).

Can anyone point me in the right direction on how to get this to work?

Would you like me to paste the full code (pastebin)?
Or is what I've provided sufficient?

Should I just have a completely separate php file to run this and just create a custom link to the url?

Any and all help is most greatly appreciated.

Thanks.

efishop on "Query week filter"

$
0
0

Hello all,
I have the fallowing php code:

$my_query = new WP_Query('category_name=Citat&showposts=1&orderby=rand'); ?>  

<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
  <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php echo get_post_meta( get_the_ID(), 'citat', true ); ?></a><br/>
<div class="autor_citat"><?php echo get_post_meta( get_the_ID(), 'autor', true ); ?></div>
<?php endwhile;

How can I add a function that display only the displays post from current week?

I have tried this: http://codex.wordpress.org/Template_Tags/query_posts#Time_Parameters but with no luck, it display tree posts instead of one.


xennex81 on "Anti-spam registrations"

$
0
0

Hey I'm just curious...

I opened up registrations on my live beta site, and immediately started receiving a (few) spam registrations.

Now I know that there are plugins that can guard against it, but I wonder if it would not be more effective to just mess with the code myself in a way that no plugin would do.

The way I see it there are only two ways a spammer can find the registration url

- it just assumes wp-login.php?action=register will do the trick
- it is going to parse the html for anything that resembles a hyperlink labeled "Register" or anything of the kind, and then follow that.

I changed the "register" action to "register-strange" to see if that would do the trick, but I had one more spam registration tonight. I have to rule out one more thing, ... alright the whole site should have only one link to the registration page left.

Anyone who can find the registration form will be able to parse it, recognise it, and use it.

But they have to follow the link called "Criminals enter here" :P.

Well, I'll have to see for the coming days. I guess the spambots are using a million different techniques. Even the name of the PHP file is a hint to follow that link...

I wonder, I wo-wo-wo-wo-wonder....

wolmah on "wp_nav_menu help..."

$
0
0

<?php wp_nav_menu( array( 'theme_location' => 'sports-menu' ) ); ?>

Is what to pull specific menus in that location on the pages i assigned.

However what is the proper if tag to ignore if page or homepage doesnt have menu in that location on specific page?

I have tried

<?php if ( has_nav_menu( 'sports-menu' ) ) : ?>
<?php wp_nav_menu( array( 'theme_location' => 'sports-menu' ) ); ?>
<?php endif; ?>

It thrown the WP off and wont even show at all. What is the right way to write? Thanks!

Dekisugi on "What to put in the action parameter of the form tag in the plugin?"

$
0
0

Hi

I don't understand how wp plugin handle html form. Say, I develop a wp plugin that has a setting page which uses HTML form to handle input.

<FORM action="" method="post">

What to put in the action parameter? Should it be blank or the filename of the plugin php file?

I saw some sample code. They put in "options.php". It made me even more puzzled because I have no idea where is that options.php file.

Please help me understand.

Thanks a lot!
Narin

r78o1k on "a-z index"

$
0
0

Hi. I am trying to add an a-z index to my home page of blog titles. I don't want to use the categories.

I am using the following code, but it doesn't seem to be working.
Home page code:
<a href="#gusto-queenscliff">Gusto Queenscliff</a>

And I have entered this at the top of the text box of the post:
<a id="gusto-queenscliff">Gusto Queenscliff</a>

I am very new at this!

friedmanm on "Need help with hyperlink in signature; site name coming up twice"

$
0
0

Sorry, not quite sure how to word this question. I've set up a disclaimer as a page, but am not showing the page on the menu. Instead, I'm trying to add a hyperlink that page in the signature.

I type in the hyperlink code, www mysitename com / disclaimer, etc, but when I save it and click on it, I get:

mysitename/http://www.mysitename.com/disclaimer, which leads me to a 404 error.

Does anyone have a solution? I did a search but couldn't find anything to match. I'm pretty new at this, so please be gentle. I read the thread at the top, so I apologize if I put this in the wrong place.

Thanks!
Mike

Viewing all 8245 articles
Browse latest View live




Latest Images