Forum Replies Created

Viewing 15 replies - 1 through 15 (of 314 total)
  • I recently cleaned this off of a client’s web server…what a mess. The client had a ton of old unused files and folders from previous versions of their website (prior to using WordPress), so I archived and removed all of those. They also had three active WordPress sites on the server (one in the root directory, two in subdirectories), so I painstakingly went through all remaining files and folders removing the injected PHP from every file named index.php, functions.php, header.php, config.php and wp-config.php.

    It is important to note that this script hit EVERY file on the server with those file names, even in unused plugins and themes. There were files in subfolders of wp-includes and wp-admin, as well as in places you wouldn’t expect deep within plugin directories.

    I also deleted hidden files called .. that would be generated in the root directory of each WordPress install any time the corrupt PHP was executed (in this case, when the mobile version of the site was loaded).

    There were other suspicious files as well, with filenames that were just a random series of letters and numbers, or that contained the phrase googlebot followed by a series of IP addresses.

    The behavior of this hack on the iPhone was such that, when the site was loaded in the browser it would start hitting a series of redirects and launch the App Store so you couldn’t close it out right away. Then, when you go back to the browser, it continues until it ends on a porn site.

    I suspect this malware was designed to generate tons of web traffic and make someone rich rather than to steal data, but who knows. It didn’t seem to affect the DB, but as a precaution I changed the DB user credentials for all of the sites.

    Plugin Author Shaun Scovil

    (@sscovil)

    I am able to download that CSV file from your URL and put in on my server, and display it using the plugin. This tells me it is either a conflicting shortcode (as I suggested above) or a file access / permissions issue on your server.

    Plugin Author Shaun Scovil

    (@sscovil)

    You might have another plugin or theme installed that also registers a [csv] shortcode. For that reason, I also made this plugin register a [csv2table] shortcode that works the same.

    Try using:

    [csv2table src=http://fakecompany.com/wp-content/uploads/2014/06/test.csv]

    Here is a function you can add to your theme’s functions.php file, which is a bit more efficient than doing a redirect: https://gist.github.com/sscovil/535de15f134be519f6e4

    Create a page called “Login” (or whatever) using the [wp-members page="login"] shortcode, grab the ID of that page, then pop it into the function on the line that reads:

    $query->set( 'page_id', '12' );

    Replace the number ’12’ with your login page ID and non-members (or members who aren’t logged in) will see the login page instead of the post index.

    This function uses the pre_get_posts action hook to modify the WP_Query object.

    Plugin Author Shaun Scovil

    (@sscovil)

    Hi there,

    Sorry for the delayed response; I recently started a new job and have been spread pretty thin, so I’m just clearing my inbox now. 🙂

    Thank you for using — and improving — my plugin! I’m always excited to see how other folks are using it and will definitely check out some of the changes you’ve made.

    Best thing to do would be to fork the plugin on GitHub: https://github.com/sscovil/csv-to-sorttable …then you could make changes, push them up to your forked repository and submit a pull request.

    If none of that made any sense and you’re not familiar with version control, feel free to just email me a copy of your modified plugin. I’ll review it and see what changes should be merged into the main branch.

    Also, I’m currently working on a new plugin that combines the functionality of this and another plugin I wrote a while back — http://wordpress.org/plugins/sorttable-post/ — and things like customer header rows are definitely something I was planning to add to that. If you’re interested, maybe we can collaborate on that as well…

    Plugin Author Shaun Scovil

    (@sscovil)

    Hi Troy,

    Sorry for the delayed response. The best format would be comma delimited, but the others should work as well. I haven’t tested them, but if you have any issues with the other formats please let me know and I will look into resolving it.

    Thanks for using my plugin!

    @vtxyzzy In that request, the ‘ORDER BY’ is set to the column ‘meta_value’, which doesn’t exist. The expectation of Jonathan (above) is that ‘meta_value’ would be replaced by ‘about_order’, which is a custom user meta field.

    To confirm, take a look at wp-includes/user.php, lines 415-437 (in WP v3.5.2). You can see how WP_User_Query handles the orderby parameter…it does not handle ‘meta_value’ as a parameter.

    The ‘orderby’ parameter does not accept ‘meta_value’ as a value. See this section of the Codex for valid options.

    In order to do what you want, you’ll need to re-order the WP_User_Query results in PHP.

    Try this:

    /* Employee Query for About page */
    function it4_get_users_with_job_title() {
        $args = array(
            'meta_query' => array(
                array(
                    'key'     => 'job_title',
                    'value'   => null,
                    'compare' => '!=' // Make sure the user's job title field has a value (i.e. job_title != null)
                )
            ), // End of meta_query
    
            'fields'  => 'ID',
            'exclude' => array( 1 ),
        );
        $user_query = new WP_User_Query( $args );
        $user_ids   = $user_query->get_results();
        $meta_key   = 'about_order';
    
        return it4_sort_users_by_meta_key( $user_ids, $meta_key );
    }
    
    /**
     * Sort Users By Meta Key
     *
     * @param array $user_ids
     * @param string $meta_key
     *
     * @return array|boolean
     */
    function it4_sort_users_by_meta_key( array $user_ids, $meta_key ) {
        $user_order = array();
        foreach( $user_ids as $user_id ) {
            $user_order[$user_id] = intval( get_user_meta( $user_id, $meta_key, true ) );
        }
        asort( $user_order );
    
        return array_keys( $user_order );
    }

    What this new function does is accept two parameters — your array of user ids, which you got from your WP_User_Query, and the meta key you want to sort your users by. It then loops through the array of user ids, assigning each user id as a key in a key=>value pair to a new array called $user_order. The values in that array are the integer values of the meta key (i.e. ‘about_order’ ).

    Finally, it runs the PHP function asort() on the new array, which sorts the $user_id=>$meta_key pairs by $meta_key, from lowest to highest, and returns a new array of $user_ids in that order.

    Hope this helps! If you have any questions, feel free to get in touch…

    Plugin Author Shaun Scovil

    (@sscovil)

    Hi Troy,

    Sorry you’re having trouble with my plugin. Please share a link to the CSV file you are trying to import. I suspect the file has some sort of formatting issue that is interfering with the parser. If so, I’d like to see it so I can try and code a solution…

    Thanks in advance,

    Shaun

    Actually, that’s not the <img> alt tag — it’s the <a> title tag, which seems to be getting assigned the value of the <img> alt tag. If the <a> tag for each image in the gallery had no title attribute, you wouldn’t see it on hover.

    Unfortunately, I’m not sure how to remove that when using the image gallery shortcode…there aren’t any parameters for that.

    Keep at it. The key to remember is that you are styling a button, but you want to only style that button under certain circumstances. The <body> tag has many classes that can help you narrow down when that button gets styled.

    The buttons themselves are:

    #menu-item-7798 a  /* North America */
    #menu-item-7861 a  /* Knowledge Center */
    #menu-item-7861 a  /* FSU */

    Adding classes and/or IDs of elements that come before them will allow you to narrow down your CSS rules to only fire under the correct circumstances.

    @vickym: Add this to your theme’s style.css file:

    .fancybox-title.fancybox-title-outside-wrap {
        display: none;
    }

    Try this:

    .category-north-america-programs #menu-item-7798 a {
        background-color: rgb(246,148,90) !important;
    }

    That will make all single posts in the category north-america-programs show the North America menu item highlighted in the main navigation.

    Use background-color instead of just background as well. This is a more specific rule, so it is less likely to be overridden by other rules.

    Hmmm…I hadn’t tested that function, but you should be able to change it to this:

    add_filter('body_class','add_category_to_single');
    function add_category_to_single($classes) {
    	if (is_single() ) {
    		global $post;
    		foreach((get_the_category($post->ID)) as $category) {
    			echo $category->cat_name . ' ';
    			// add category slug to the $classes array
    			$classes[] = 'category-'.$category->slug;
    		}
    	}
    	return $classes;
    }

    Not sure why that second function parameter was there…

    At first glance, the problem appears to be that, as you drill down further you switch from Pages to Posts. Pages are hierarchical, as are Post Categories, but your site architecture is mixing the two and there is no easy way of knowing which posts belong to which parent page.

    That said, you could add the following function (found here) to your functions.php file:

    add_filter('body_class','add_category_to_single');
    function add_category_to_single($classes, $class) {
    	if (is_single() ) {
    		global $post;
    		foreach((get_the_category($post->ID)) as $category) {
    			echo $category->cat_name . ' ';
    			// add category slug to the $classes array
    			$classes[] = 'category-'.$category->slug;
    		}
    	}
    	// return the $classes array
    	return $classes;
    }

    Then you can associate post categories with the appropriate navigation menu links, like this:

    .example-category #menu-item-7798 a,  /* North America */

    View the source of your website in your web browser while on one of the single post pages to see the classes that are added to the <body> tag.

Viewing 15 replies - 1 through 15 (of 314 total)