• So what exactly is $args because I see it everywhere. I was getting Warnings from Theme Sniffer about not escaping paginae_links. I tried my hardest to figure it out but I had to look at another theme to get what I posted in the title. But the code had wp_kses_post( paginate_links( $args ) ).

    All I know is that it worked without getting the escape warnings with and without $args, and I didn’t create an args variable anywhere, but maybe Underscores has it in some file. So what is $args and why do you need to use it?

Viewing 6 replies - 1 through 6 (of 6 total)
  • $args isn’t anything until you assign it something.
    You should read all the section in the Security section of the Theme Developer Handbook to better understand escaping and sanitization.

    There are other functions for pagination links and navigation links. The pagination ones are for when there are multiple on a page, such as archive pages, and the navigation ones are for when there is only one on a page, like single post pages.

    The thing about the post title is that it is one of the few fields that can contain HTML, so normal escaping can make it look wrong.

    Thread Starter Jim

    (@kernix)

    I read all but the advanced theme topics and I still find the escaping part confusing. I’ll just have to experiment with all of them I guess. I also looked at the_posts_pagination();. For now, everything is good but I don’t understand when to use one versus the other for some of these things.

    Moderator bcworkz

    (@bcworkz)

    WP passes $args style data to functions so we can supply any number of various arguments, omitting ones where the default value is acceptable. It gives us better flexibility and yields more readable code over something like some_wp_function($id,$author,$cat,$tag,$tax,$s,$p,$type,$status)

    Escaping is confusing. Compounding the confusion is sometimes WP functions manage this, other times not. You did the right thing in looking at how other themes handle something. Just be sure to use an accepted, well written theme as guidance ?? Just remember the basic goal: Data coming in and data going out both need to be protected from malicious code being attached. You may need to examine related source code to determine if WP is escaping data or not. Functions with names including strings like “kses” and “esc” sanitize and escape data.

    All the various pagination functions are also confusing. Often there can be a number that will work, other times only one. The first thing to determine is are you paging through pages with multiple posts each, or one post each? Note the functions can have both singular and plural forms. the_post_navigation() vs. the_posts_navigation(). Once again, when in doubt, look to well written themes for guidance on what to do.

    Thread Starter Jim

    (@kernix)

    Thanks. I looked at OceanWP for the escaping of the pagination. Is $args just general or does it need to be defined somewhere? I try the pagination with and without it and the pagination worked in both cases – and the pagination is for archive pages.

    I also and using esc_attr for get_post_format

    <span class="dashicons dashicons-format-<?php esc_attr(get_post_format( $post->ID )); ?>"></span>

    I could have sworn it worked but the dashicons for the post types eventually disappeared. It seems a lot of people poo-poo the post formats except for maybe gallery and image, but I like them as possible quick weekly posts when you are behind on time. Especially aside, quote and status. I eventually want to style them to look fantastic. But since I’m getting escaping errors and the code above didn’t work, I’ll probably remove the display of the icons for the post types. Also because I think those are only for display in the admin area.

    Whew… a lot to learn but at least I’m learning something new every day. I have a to-do list and every time I check one off I add two more items.

    Moderator bcworkz

    (@bcworkz)

    $args has to be assigned a value if you use it. It’ll generate undefined variable warnings if you don’t. You can often not pass anything and accept the defaults. Passing an undefined variable has the same effect as not passing anything, except it’ll also fill your error log with warnings.

    The post formats are nice for blogging. A lot of WP sites do not have a blog component, so they then serve little purpose. Support by themes is optional, they need to opt-in through add_theme_support() if they’re going to support post formats.

    Post format icons would be a nice feature. There ought to be a way to incorporate them if nothing else interferes. As it’s not a must-have feature, it’s best to get your theme functioning cleanly before adding bells and whistles. Font based icons can be added using the CSS ::before pseudo-selector along with a content: rule. The icon font does need to be properly loaded onto pages for such CSS to work.

    Ah yes, the ever growing to-do list ?? Try not to feel overwhelmed, focus on one item at a time. You will eventually get through it all, but concern over how much more there is to do is not productive. Much like the mountaineer’s rest step, deliberate slow and steady is what gets you to the summit.

    Thread Starter Jim

    (@kernix)

    Thanks – that’s what I’ve been doing. My Theme Check gave me all green so I’m good there, but I have a few issues from Theme Sniffer and one of them is an error I can’t figure out. Been working all day on image, video, and attttachment.php – almost done with them. Then I have to redesign my sight and I do need some bells and whistles when it comes to the CSS stuff.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Question about wp_kses_post( paginate_links( ) ) and $args’ is closed to new replies.