How To Display BuddyPress Profile Data On WordPress Multisite Blogs

Displaying BuddyPress profile data outside of the main BuddyPress components is a little trickier than you might imagine. However, this is a common request, especially since many of our readers manage multisite networks. So for this quick tip we’re going to examine a few examples of displaying BuddyPress profile data on multisite blogs.

Basic Example of Displaying BP Profile Info on a Multisite Blog

A very common scenario is where you want to display an author’s bio on his multisite blog, pulling the content from a BuddyPress profile field. The code below gets the blog admin’s user ID and displays the profile field that you specify. You only need to replace the ‘Bio’ with the name of the field you’re trying to display:

1
2
3
4
5
6
7
<?php 
global $  bp;
$  thisblog = $  current_blog->blog_id;
$  user_id_from_email = get_user_id_from_string( get_blog_option($  thisblog, 'admin_email'));
$  myfield = xprofile_get_field_data( 'Bio', $  user_id_from_email );
echo $  myfield;
?>

Continue Reading

One month on: does “pay what you want” work for WordPress themes?

Lots of posts on WPShout are art directed, so you may wish to view this in your browser –> One month on: does “pay what you want” work for WordPress themes?

Ever since I launched Empty Spaces last month as a free/pay-what-you-want theme, I’ve been asked repeatedly whether people are actually paying when they can just download the theme for free, and as an extension of that, whether “pay-what-you-want” actually works.

In this post I’m going to answer those two questions… or at least try to. Let’s get going.

So has anyone actually paid for your free theme?

Yes! I’ll run through some of the key data points from the first 26 days of Empty Spaces’ availability:

  • Total downloads: 100.
  • Paid downloads: 6.
  • Range of amount paid: £1 to £10.
  • Total revenue: £41.
  • Most frequent price paid: £10.
  • Total views of the download page: 300.
  • And thus — conversion rate of visitors:downloads: 33%. Continue Reading

Swiftype: The Best Search Solution For WordPress

Despite WordPress’ world class publishing capabilities, the native search function leaves something to be desired. In fact, on larger sites it can be damn near impossible to find what you’re looking for. We set out to find the best possible search solution for WordPress and have been completely blown away by Swiftype.

This revolutionary app allows you to tailor your site’s search results to help users find the most relevant content. The app works alongside WordPress via a plugin and gives you the ability to fine tune search queries. Essentially you’ll be creating your own search engine that is more efficient and user-friendly than the WordPress default.

Replace BuddyPress Friends Functionality With Followers

Every BuddyPress site has different requirements for how users should be able to connect. The built-in friendship functionality of BuddyPress is not appropriate for every social network. This is especially true for professional networks. In many instances you may want to replace the friendship component with followers instead. Luckily, there’s a plugin that does that for you.

The BuddyPress Follow plugin is what you’re looking for. It allows members to follow other members activity and has just been updated to be compatible with BuddyPress 1.7. The plugin adds a new activity stream tab, follow/unfollow buttons to member profiles and a new tab to display the users following/followers in the members page along with total counts.

What are the differences between Friends and Followers?

Follow button replaces the Add Friend button

Friending and following are very similar but have one main difference. Following does not have to be reciprocated, whereas friendship must be approved by both parties. Following works just the same way the Follow button works on Twitter.

Please note that it is not recommended to have the native friends component turned on when using the followers plugin. This would probably cause confusion to users who may not know the difference. If you want to change your BuddyPress site to use followers instead of friends, install the BuddyPress Follow plugin, available for free in plugin repository.

Related posts:

  1. BuddyPress Followers Plugin: A Different Way For Users to Make Friends The new BuddyPress Followers plugin is now available. It has…
  2. BuddyPress Private Messages for Followers Only Now Available Cut down on annoying private messaging spam with this new…
  3. Assign Automatic Friends to New Users on Your BuddyPress Site Nobody likes to sign up to a new social network…

 

An Invitation – Write for WPMU, for $$$s, Exposure and FAME

As you might have noticed, we’ve been raising the bar here at WPMU of late.

We’re committed to bringing you the absolute best in WordPress tutorials, resources, reviews, news and interesting, topical articles.

And, well, we’d like to invite you to join us, and we’d like to make it more than worth your while too – please consider this your official invitation to become a writer at WPMU.

 

Here’s how it works:

  1. You submit a pitch to us (a title, summary, couple of paragraphs and some links to your other work)
  2. We’ll get back to you with a yay or nay
  3. If it’s good we’ll set you up as a Contributor, give you an editor and away you go
  4. When the piece is published we’ll swiftly PayPal you up to $ 500

Did I mention the up to $ 500 part :) Here’s the breakdown:

  • Great tutorial – $ 200
  • Premium article – $ 300
  • Truly epic post – up to $ 500

Examples of what these constitute here.

It’s our reckoning that a good writer can, amongst other things, easily put together two or three tutorials / premium pieces, and manage an epic post, in a week – so you could easily earn over $ 1000 / week writing here (and, needless to say, we’d feel compelled to offer you a full time job if you wanted it too :)

And that’s not all, the exposure that a successful gig at WPMU can get you is pretty amazing too. Ex writer Siobhan McKeown now works with Matt Mullenweg at Audrey Capital, Tom Ewer is going from strength to strength and of course our very own Sarah Gooding is partner in one of the best WordPress development agencies out there. Beat that!

Interested? You should be.

Find out heaps more and submit your first article pitch here.

Any questions or suggestions – let us know in the comments.

Related posts:

  1. Want to write for WPMU.org… oh and we’ll pay you too! We’ve got an opening at Incsub for another writer to…
  2. Want to Write for WPMU.org? We’re looking for guest bloggers to write up a storm…
  3. Would you like to write and tweet for WPMU.org? We’re thinking about hiring someone to write about WordPress MU,…

WPMU.org

Where are the Women in WordPress?

Since my first Programming 101 lecture at college 10 years ago where I was just one of five women in my class, it seems not a lot has changed.

Back then, the stares of a hundred pimply nerds trying to pass off bum fluff for facial hair burned my skin. No doubt they were all wondering what the hell I was doing there, invading their territory, their space to avoid the needless stress of making small talk with the opposite sex.

Gender inequality in tech is nothing new. All of my computer science lecturers, bar one dalek-obsessed woman with a hint of a moustache (“It’s dah-lek, not day-lek!”), were men.

So when I went along to a friend’s computer science college graduation ceremony recently, I was disappointed to watch as, one by one, men crossed the stage to receive their degrees.

And where else is there usually a sausage-fest of men? Oh yeah, WordCamps.

WordCamps can be a case of spot the woman.
WordCamps can be a case of spot the woman.

Where are the women? Has really nothing changed in 10 years?

Are Women Their Own Enemy?

At last year’s first WordPress Community Summit, a gathering of the who’s who of the WordPress world, just 12 of the people there were women. Naturally, they got together to talk about that fact.


Do women sabotage themselves by underrating their abilities?

They discussed the lack of women applying to present at WordCamps, where speakers are usually men on the developer track. It’s an issue for the tech industry as a whole, where conferences are usually a flood of white men. It’s been said that women often turn down invitations to present because they feel the need to have a PhD on a topic, whereas when men are asked they’re more likely to say, “Yeah, I know a bit about it. Sign me up.”

Then there’s “imposter syndrome.” When women are complimented on their skills, many immediately think to themselves, “I’m not that great.” Most guys accept the compliment and believe it.

It was also noted at the summit discussion that many women don’t think they’re smart enough and feel like outsiders despite the incredible work they do, and some women who work in development tell people they’re not a developer.

More Women Need To Get Involved

This month, Shannon Smith of Cafe Noir Design will run her third unconference in three years exploring the role of women in the WordPress community and the fact we make up more than half the bloggers but only about a quarter of WordCamp speakers and an even smaller number of developers, coders and contributors at WordCamp Ottawa this month.


Women’s voices should be heard in WordPress.

“Where are the women? Why aren’t they participating? And when are they participating? Why don’t we see them? And more importantly, how can we even out that imbalance?” Smith says.

“Tech dominates our lives, our society. It influences the way we live, what we learn and how we live. At the moment it is directed by, organized in the benefit of (though perhaps unconsciously), and produced by an unequal segment of the population.

“Until technology is controlled by a diverse cross-section of society, it cannot serve all of society. Blogging, by its nature, encourages a diversity of voices. It would be great if that diversity in blog production was also reflected in a diversity in blogging tool production.”

Why Do We Need More Women?

So why exactly do we need more women in WordPress? I’m glad you asked…

1. Diversity Improves Performance

A Cornell University study proves diversity improves performance and morale, not to mention the end product. And since 39 per cent of visitors to wordpress.org are women – and probably even more are users of WordPress software – it makes sense that women are more equally represented in creating the end product. More women engineers means building a better WordPress and improving it for society as a whole.

2. Future Jobs are in Tech


Hiring Nerds — Will that also mean hiring women?

As Sara Chipps points out, there are six million information technology jobs in the US, up from 628,000 in 1987, and then 1.34 million in 1997. At the moment, jobs in the tech sector have half the unemployment rate of the rest of the workforce, and this ain’t changing any time soon.

If growth continues at the current rate, it won’t be long before women won’t be able to find work if they are not qualified to work in tech. We need to better educate girls and encourage them to get involved in communities like WordPress now so in the future they are not the poorest members of society.

3. Women Bring Diversity of Thought

Women think, act and approach problems differently to men. While men, in general, are naturally more prone to risk taking and competition thanks to their increased testosterone, whether it’s cultural or biological, women tend to be more emotionally and socially sensitive, empathetic, are better collaborators and are better at achieving long-term results. Diversity of thought in business and having a company made up of people who approach problems in different ways can only be a good thing.

4. Women Can Talk to Women

Women make up more than half of bloggers, including many small business owners who need websites. If no one can understand their needs, can talk their talk or build and design appropriate products for them, then that’s a massive chunk of the market — and not to mention profits — that WordPress is missing out on.

Take car manufacturers, for example. They have quickly cottoned on to the fact that women influence 80 per cent of car purchases and have changed their designs and marketing campaigns accordingly. Even Volvo, marketed for its solidity and reliability, employs more women. When my heavily pregnant sister-in-law went looking for a new car, she wouldn’t look at any other make of car.

This 1957 ad shows that Volvo has known for a long time about how important women are in their marketing and to their company.

5. Women are Good for a Company’s Bottom Line

After years tracking the performance of about 200 of the Fortune 500 companies, a 19-year Pepperdine University study consistently found the correlation between high-level female executives and business success was “consistent and revealing.” And the better a company was at promoting women, the better it tended to rank in terms of profitability.

This is something WordPress should certainly take note of — WordPress’ core and contributing developers and developer emeriti are all men. Just two women are part of the core team.

Women Have Run Out Of Excuses

We know there are women out there quietly working with WordPress, tapping away on their keyboards, creating beautiful websites and playing with code. I want them to come out of hiding.

There is no excuse to sit back and let the boys have all the fun. There are plenty of ways to get involved in the WordPress community.

1. Share your knowledge. At a recent London WordCamp Siobhan McKeown outlined ways people can contribute to WordPress:

  • Developer (Core, Documentation, Plugins, Mobile Techno)
  • Designer (User Interface, Documentation, Mobile Design, Theme Review)
  • Writer (Codex, Handbooks)
  • Linguist (WordPress Translation, Document Translation, Plugins, Multilingual Support)
  • Teacher (Teaching, Sharing Courses, Support)
  • Organizer (WordCamp, Meetups)

2. Get Involved. Getting involved is as simple as clicking “Get Involved” at wordpress.org. Joe Foley has a ripper write-up about it.

3. WordCamps. There were 67 of them held around the world last year — and even more this year. Go along and watch, or better yet, present.

“I knew there must be other people like me looking for design topics, so I decided to give a few,” says user interface designer Mel Choyce who presented at New York and Philadelphia last year. “There’s a good chance you’ll feel totally unqualified, but everyone thinks that at first. Many people still feel that way. You have nothing to lose from applying to speak.”

4. Meetups. With 430 WordPress Meetup groups listed online, there’s bound to be one in your area.

On the first Monday of every month, members of the Albuquerque’s women working with WordPress “sister” Meetup group get together to pick each other’s brains. Organiser Karen Arnold says this month the ladies met to discuss their current projects.

“One woman had a website she wanted feedback on so we pulled it up on the projector and as a group we helped her solve some issues she’d been having,” Arnold says. “Another woman shared a project she’d been working on that she just wanted to show off since she was so excited about the project.”

Co-organiser Samantha Metheny says women often feel more comfortable about their place in the tech world when they see how many other women are involved, too.

Women need not face the waves alone. There are others out there too. Sometimes you simply need to reach out to find them.

Getting involved in the WordPress community might seem daunting at first, but everyone’s been there. It’s not as if you’re going to receive a formal invite for exclusive access to the secret WordPress society. WordPress is open source – by the community for the community, so just get stuck in.

“I think the WordPress community is encouraging to anyone who is jumping in and getting involved. This has nothing to do with gender,” Untame partner and developer Sarah Gooding says.

It’s Not All Doom And Gloom.

A handful of successful woman offer a glimmer of hope.

Lisa Sabin-Wilson


Written by a woman.

Lisa Sabin-Wilson’s story is almost legend — she was a registered nurse for 12 years and worked on websites in her spare time before walking into her boss’ office one day to hand in her 30-day notice of resignation. She has since written five editions of WordPress for Dummies and is a partner at WebDevStudios.

Andrea Rennick

Then there’s Andrea Rennick, who started out as a blogger in the homeschooling community. Rennick wanted to start a website for other parents who were homeschooling and stumbled across the early stages of the WordPress Multisite project. She works with Copyblogger and has co-written several books on WordPress.

Siobhan McKeown

Another success is McKeown, who started out as a writer on this very website. She has gone on to run Words for WP, is an editor at Smashing Magazine and recently started a new role at WordPress founder Matt Mullenweg’s angel investment company Audrey Capital.

McKeown says the growing number of women prominent in the WordPress community due to their skills and expertise — not the fact they wear a bra — provide excellent role models for young female techies looking to get their foot in the door.

“Their very presence shows what is possible and makes it easier for women who are starting out to see themselves inhabiting that role,” McKeown says.

Jen Mylo

Automattic’s Jen Mylo can’t be left off this list. She has been the UX and community lead for WordPress for several years, more recently taking on a greater role focusing on encouraging women and diversity in the WordPress community. In her pre-web life, she was a cook/baker and managed healthy cafes and kitchens in tourist lodges.

In December, Mylo announced her role would be focusing more on increasing diversity in contributor groups, starting with the gender gap. Hence, the Community Outreach contribution group was launched.


Matt Mullenweg convinced Mylo to work with Automattic in part by opening the door to working with women and WordPress.

“When Matt (Mullenweg) convinced me to take the job at Automattic, one of the things that got me in was that he said I could work on programs to bring women and girls into the WordPress community, especially around programming,” Mylo says on her blog.

“In that lunch on a San Francisco sidewalk, I laid out a vision including mentoring programs, school projects, summer camps, trips to the moon… okay, not trips to the moon, but just about everything under it.

“I keep going back to that sidewalk lunch and how exciting it was to talk about possibilities around using WordPress as a gateway for women, girls, low income kids and minorities of all stripes who are under-represented in our community to get into the web industry.”

Since that post, Mylo launched her first initiative, a workshop series open only to women, in Washington DC and San Diego last month. The troubleshooting workshops helped participants learn about common errors, CSS fixes, software conflicts and hacks and viruses.

So What Next?

It’s all well and good to have women-only workshops, but getting a handful of women together in Washington DC to pick through their CSS isn’t exactly groundbreaking.

What we need is a plan to lift the number of Women actively involved in the WordPress community. This is what I propose:


Getting in the WordPress game.
  • More women at the top. We need more women in the core team developing WordPress. We need to push female developers who are sitting back and watching to get more involved and show us what they can do.
  • Set quotas for women involved in WordCamps. Positive discrimination is not only symbolic but will give women the confidence and encouragement needed to voice their ideas and opinions to the community.
  • Target school age girls. We need to target girls early and educated them about tech and the WordPress community and the opportunities available. Workshops and talks at schools giving girls the chance to play with WordPress and learn how to blog would be a great start.
  • A roadmap with achievable targets. There’s no point throwing around ideas if we don’t have something to work towards. Since half of bloggers are women we should work towards ensuring half of those involved in the WordPress community are also women.

Tell us what you think below.

Image credits: Ray from LA, Randy Stewart, epSos.de, Thomas Tolkien, Laihiu, Judi Knight, Keijo Knutas.

Photo: negative from BigStock

Related posts:

  1. Commercial WordPress Themes Made Just For Women Coming Soon Lisa Sabin-Wilson and her friends over at iThemes have been…
  2. Allure Themes Launches New Theme Shop Featuring WordPress Themes for Women We’d like to introduce you to a brand new WordPress…
  3. BuddyPress News: Create Your Own Private BuddyPress Community Many users have asked in the forums about how to…

WPMU.org

Taking stock: how WPEngine triggered a revolution in WordPress hosting

Lots of posts on WPShout are art directed, so you may wish to view this in your browser –> Taking stock: how WPEngine triggered a revolution in WordPress hosting

WordPress hosting has seen a revolution over the last couple of years, with a huge shift away from cheap, crappy shared hosts and a move towards expensive, quality, managed hosting. In the space of three years, paying for quality hosting has become the norm, and for the firms at the forefront, it’s big business.

There’s a reason that managed hosting has been so successful — a lot of firms are offering brilliant services with everything you could need included and users are recognising there’s value in that. One such person is me; I made the switch to WP Engine late last year, and I’ve been very happy since.

As I said in a WPShout newsletter at the time, I immediately noticed things like loading speeds going down, causing a drop in the bounce rate and an increase in visits. Those are the kind of reasons why managed hosting is worth the price tag.

And so, with WP Engine hitting the headlines recently as it makes apparent moves towards gearing up towards making an IPO, I thought it’d be a good moment to take a look at its meteoric rise to the top of the pile in the WordPress hosting market, and see how they’ve served as a catalyst for everyone getting into managed hosting.

I’ll note quickly: I’m using affiliate links in this post because I genuinely really like WPEngine. I’d appreciate it if you used them, but don’t feel obliged to. I’m not being paid to write this… sadly.

Where it all began

For this post I’ve had the pleasure of sitting down via email with Austin GunterEngine’s “community manager guy” (my words, not his). Austin has done some very impressive work spreading WP Engine’s reach recently and is very well qualified to speak on behalf of the firm. We’ll get to it, then; I asked Austin where it all started out:

WP Engine started as the brainchild of Jason Cohen and Ben Metcalfe. Jason is a repeat entrepreneur and the author of a startup blog, ASmartBear.com, where he often would often get on HackerNews and see an influx of traffic. The blog was built on WordPress, of course, and Jason saw firsthand the need for a hosting company that could handle traffic spikes and also manage security concerns while providing amazing support.

I like this. Sadly I don’t get huge influxes of traffic from HackerNews or Reddit (yet!), but I’m pretty sure we’ve all been somewhere near there: someone influential tweets about or links to something you’ve posted, traffic spikes big time and instead of enjoying your largest-traffic day, you’re left with 40 second loading times and a whole bunch-full of missed opportunities.

So — WP Engine was built out of a need to provide hosting which didn’t buckle under the thought of lots of traffic, which is the kind of thing you want your host to do for you, really. Austin mentions Engine was “built around the idea that “hosting WordPress shouldn’t be so painful””, and you see that in some of the features on offer: a staging area (with the ability to push from staging to production), Git integration, auto-updates, actual WordPress support and so on.

It’s everything you want in a host, really. It’s approach which has been one of the reasons why Engine have grown so quickly, Austin says:

Listening to customers and responding quickly [has been important]. This means a lot of different things depending on the type of company, but for WP Engine it means the following. We listened early to the features that WordPress developers wanted, like auto updates, daily backups, and a staging area, and we built those. We knew that if we made it simple to build amazing sites on WP Engine, if we made developers and designers lives easier, we’d be able to grow.

Everybody’s doing it

As I mentioned up top, WP Engine have sparked a mini-revolution. Managed hosting is now something everyone wants to offer you. Whilst that’s less good for Engine, it’s awesome for us — the consumers. Fierce competition drives innovation and drives down prices, and whilst the competition is all very friendly, it’s often played out very publicly on Twitter, a trend driven by what I expect is a big% of customers being hugely active on the platform.

From a community management point of view, I’m not sure if that’s a blessing or a nightmare. I’ll go with “interesting challenge”; it’s certainly an interesting position to be in, where one tweet from one influential customer can make or break your day — or week. Austin mentioned how social media has played a big part in “spreading the word” about WP Engine:

Engagement on Social Media, specifically Twitter has also been huge. We’ve found that our customers really love being able to talk to us on social media. As well when prospective customers are evaluating whether or not to sign up for WP Engine, our established customers will respond before we can with their honest experience, which is usually pretty stellar! Of course, they wouldn’t support us so strongly if we didn’t work so hard to thrill them on the customer support side.

Austin — I’d be interested to see what Twitter search terms you monitor ;)

It’s a serious point, though; for WP Engine and its competitors, monitoring the social media conversation around the brand is vital, and being an effective part of that conversation is even more important. Social media engagement comes under the larger strategy of “community involvement”, and whilst it’s unfashionable to talk about “the WordPress Community”, it’s clearly a tangible, trackable thing for the Engine crew:

One of the keys for WP Engine has been to stay active as contributors to the Community. We attend 20-30 WordCamps a year, and sponsor meetups all over the country. Frankly, we’ve seen that the more we support the WordPress Community with our time and otherwise, the better our growth is. The Community values have been a foundation from the very beginning, but it’s really cool to be part of a company that exemplifies how you can “do well by doing good!”

Powering the future

Managed hosting isn’t for everyone, and it doesn’t try to be for everyone. I still have some of my sites on a shared hosting plan because for 100 visitors a month it’s not entirely cost-effective to use managed hosting. But for sites where it does matter, where security, uptime, load times and support are vital, managed hosting makes big sense.

Competition is driving a huge amount of growth and innovation, and as a customer, I’m really excited to see what’s next. Features like Engine’s new user portal which allows you to push from staging to production are actually genuinely useful, and I’m really excited to see what’s next.

So — thanks, guys, and if you’re in the market for a super-fast new host, check ‘em out.

This is a post from WPShout. If you enjoyed the post, please head over to the site and share or leave a comment! –> Taking stock: how WPEngine triggered a revolution in WordPress hosting


WPShout.com

How recent is “recently”?

If you deactivate plugins you can access them some time under the “Recently active” link in the plugin list table.

recentlyactive

“Recently” is not a very specific statement. So how long are deactivated plugins assumed to be “recent”? To find this out we have to take a look at the source code. In wp-admin/plugins.php line 166 the option “recently_activated” gets updated if a plugin is deactivated:

if ( ! is_network_admin() )
  update_option( 'recently_activated', array( $  plugin => time() ) + 
  (array) get_option( 'recently_activated' ) );

The option contains an associative array containing the path to the main file of the plugin as the key and the time the plugins have been deactivated (as a unix timestamp) stored as a serialized value:

183 recently_activated a:1:{s:21:"hello-dolly/hello.php";i:1357900255;}

Before the plugin table is created the time stamp is used to determine the “recently active” plugins (wp-admin/includes/class-wp-plugins-list-table.php line 76):

$  recently_activated = get_option( 'recently_activated', array() );

foreach ( $  recently_activated as $  key => $  time )
  if ( $  time + WEEK_IN_SECONDS < time() )
    unset( $  recently_activated[$  key] );
update_option( 'recently_activated', $  recently_activated );

The code is walking through all plugin names stored in “recently_activated” and removes those which are older than one week and saves the others back in the options table.

So the answer to the question is: WordPress defines “recently” as one week.


© WP Engineer Team, All rights reserved (Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)

WP Engineer

Filename cache busting for WordPress styles and scripts

To embed custom CSS styles and scripts in WordPress you should use the wp_enqueue_script(), wp_enqueue_style(), wp_register_script() and/or wp_register_style() functions. Each of these functions allows you to define a version. By default it’s the version of WordPress. The version identifier will be in the URL to the script as a query string.

The version identifier is used to expire the URL. Since the browser detects the new URL as a new resource, it will use the new instead of the cached resource.

Sadly not all endpoints respect the query string. From Google Developers:

Most proxies, most notably Squid up through version 3.0, do not cache resources with a “?” in their URL even if a Cache-control: public header is present in the response. To enable proxy caching for these resources, remove query strings from references to static resources, and instead encode the parameters into the file names themselves.

So the goal is to encode the version identifier into the filename without renaming the resource on the filesystem. This is where the following plugin comes in.

<?php
/**
 * Plugin Name: Filename-based cache busting 
 * Version: 0.2
 * Description: Filename-based cache busting for WordPress scripts/styles.
 * Author: Dominik Schilling
 * Author URI: http://wphelper.de/
 * Plugin URI: http://wpgrafie.de/880/
 *
 * License: GPLv2 or later
 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
 *
 * 
 * Extend your .htaccess file with these lines:
 *
 *   <IfModule mod_rewrite.c>
 *     RewriteEngine On
 *     RewriteBase /
 *
 *     RewriteCond %{REQUEST_FILENAME} !-f
 *     RewriteCond %{REQUEST_FILENAME} !-d
 *     RewriteRule ^(.+)\.(.+)\.(js|css)$   $  1.$  3 [L]
 *   </IfModule>
 */


/**
 * Removes the `ver` query string of the source and places it into
 * the filename. Doesn't change admin scripts/styles and sources
 * with more than the `ver` arg.
 *
 * @param  string $  src The original source 
 * @return string
 */
function ds_filename_based_cache_busting( $  src ) {
	// Don't touch admin scripts
	if ( is_admin() )
		return $  src;
	
	return preg_replace(
		'/\.(js|css)\?ver=(.+)$  /',
		'.$  2.$  1',
		$  src
	);
}
add_filter( 'script_loader_src', 'ds_filename_based_cache_busting' );
add_filter( 'style_loader_src', 'ds_filename_based_cache_busting' );

You can grab the plugin from GitHub. After that you have to extend your .htaccess file with the lines from the docblock.

If you are using nginx you can use these lines:

location ~ ^(.+)\.(.+)\.(js|css)$   {
    alias $  1.$  3;
}

© WP Engineer Team, All rights reserved (Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)

WP Engineer

WordPress Theme Customizer Custom Controls

The Customizer is a relatively new way of WordPress Themes to provide you with options. Here is the visuality important, arrange the options directly in frontend for the Theme, play and save the settings.

We show you how to create your own classes to extend the controls, since not all fields and requests are in the core already. You can access existing solutions of the community or create your own classes. The first step is therefore a brief introduction for new classes and following an overview of some classes. Please extend this list via the comment form.

the-customizer-wordpress-themes-gestalten-640x406

The following short video shows you how it looks like. I have installed various fields that are usually used and a number of issues arise in the coding. Similarly, a separate class has been incorporated as an extension of the customizer, to use text areas.

Structure of class

if ( class_exists( 'WP_Customize_Control' ) ) {
     class Example_Customize_Textarea_Control extends WP_Customize_Control {
          // todo
     }
}

Methods of class

A number of methods are available and can be overwritten.

  • enqueue() – Enqueue control related scripts/styles.
  • value() – Fetch a setting’s value. Grabs the main setting by default.
  • to_json() – Refresh the parameters passed to the JavaScript via JSON.
  • check_capabilities() – Check if the theme supports the control and check user capabilities.
  • maybe_render() – Check capabilities and render the control.
  • render() – Render the control. Renders the control wrapper, then calls $ this->render_content().
  • render_content() – Render the control’s content.

Example Enhancement

As a brief example we will create a class that enables you to use textarea elements in the customizer. The most important method is render() and it has to appear all the markup and output objects. Constructor and declared variables are not mandatory.

<?php
/**
 * Customize for textarea, extend the WP customizer
 *
 * @package    WordPress
 * @subpackage Documentation
 * @since      10/16/2012
 */

if ( ! class_exists( 'WP_Customize_Control' ) )
	return NULL;

class Example_Customize_Textarea_Control extends WP_Customize_Control {

	/**
	 * @access public
	 * @var    string
	 */
	public $  type = 'textarea';

	/**
	 * @access public
	 * @var    array
	 */
	public $  statuses;

	/**
	 * Constructor.
	 *
	 * If $  args['settings'] is not defined, use the $  id as the setting ID.
	 *
	 * @since   10/16/2012
	 * @uses    WP_Customize_Control::__construct()
	 * @param   WP_Customize_Manager $  manager
	 * @param   string $  id
	 * @param   array $  args
	 * @return  void
	 */
	public function __construct( $  manager, $  id, $  args = array() ) {

		$  this->statuses = array( '' => __( 'Default' ) );
		parent::__construct( $  manager, $  id, $  args );
	}

	/**
	 * Render the control's content.
	 * 
	 * Allows the content to be overriden without having to rewrite the wrapper.
	 * 
	 * @since   10/16/2012
	 * @return  void
	 */
	public function render_content() {
		?>
		<label>
			<span class="customize-control-title"><?php echo esc_html( $  this->label ); ?></span>
			<textarea class="large-text" cols="20" rows="5" <?php $  this->link(); ?>>
				<?php echo esc_textarea( $  this->value() ); ?>
			</textarea>
		</label>
		<?php
	}

}

The resulting class I use, for example, in the theme documentation, downloads and maintenance status on Github. Alternatively, you can grab the class from the project WordPress-Theme-Customizer-Custom-Controls on Github, expand, improve, where there are other classes.

Collection of classes that extend the controls of the Customizer:


© WP Engineer Team, All rights reserved (Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)

WP Engineer