Filed under: reader

Implementing a loose MVC structure within WordPress

If you’ve spent any time on the WordPress Codex, this kind of code is probably very familiar to you:

<!-- Start the Loop. -->
 <!--?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?-->

 <!-- The following tests if the current post is in category 3. -->
 <!-- If it is, the div box is given the CSS class "post-cat-three". -->
 <!-- Otherwise, the div box will be given the CSS class "post". -->
 <!--?php if ( in_category('3') ) { ?-->
 <!--?php } else { ?-->
 <!--?php } ?-->

 <!-- Display the Title as a link to the Post's permalink. --></pre>
<h2></h2>
<pre>
 <!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. --></pre>
<small><!--?php the_time('F jS, Y') ?--> by <!--?php the_author_posts_link() ?--></small>
<pre>

 <!-- Display the Post's Content in a div box. --></pre>
<div></div>
<pre>
 <!-- Display a comma separated list of the Post's Categories. -->

 Posted in <!--?php the_category(', '); ?-->
 <!-- closes the first div box -->

 <!-- Stop The Loop (but note the "else:" - see next line). -->
 <!--?php endwhile; else: ?-->

This style is so common in the WordPress community that it’s essentially standard practice. It’s also difficult to read, frightening to an HTML developer who isn’t familiar with PHP and WordPress coding standards, and very conducive to duplication.

At Streetwise Media we’re shipping alot of code every week, and doing things with our WordPress installation that are far from out-of-the-box. With a complex and rapidly growing codebase, we need to ensure our code is clean, DRY, and easily maintainable.

Enter MVC.

While there are a few existing frameworks that attempt to implement this in a familiar way via WP plugins, we chose to leave things a little bit looser with our codebase, to allow some flexibility, and avoid introducing unnecessary dependencies.

Essentially, our custom WordPress code tends to break down into the following elements:

Models: Whenever a feature or product will interact with a specific set of data, we build classes that provide all the necessary methods to store and retreive the data involved. This ensures we can work with the dataset from anywhere in our codebase, in a consistent manner. For example here’s how we might add data to a custom table that stores data responsible for tracking the “likes” you see on our comments:

<?php
$likeable = array( /* data properly formatted for model */ );
$like_model = new BInnoLike();
$like_model->add($likeable);
?>

This makes it very easy to store new data from anywhere in the codebase, and the model does the job of validating the data passed to it, so we always know that any data stored is stored consistently.

Views: We forego the WordPress custom of mashing together HTML and PHP in one big pile, in favor of a more readable and re-usable templating option. Our views consist of only valid HTML, thanks to Gabor De Mooijs Stamp. A typical view might look like a longer version of this:

<!-- item_region --></pre>
<h4><!-- title --><!-- /title --></h4>
<img src="<!-- src --><!-- /src -->" alt="" />
<!-- subtext --><!-- /subtext -->

<!-- /item_region -->

Typically longer views will be stored in their own files, with .tpl as an extension.

Helpers: These are classes which provide the methods necessary to populate our views using appropriate data retreived from our models. For smaller products, such as our channel directory, a custom page template may contain nothing more than a helper function, which retieves data from a model and populates a view. In larger projects, they will generally be stored alongside the model classes. A helper function to populate the above view example might look like this:

<!--?php $model = new dataModel(); $data = $model--->retrieve(); //populate an array of data to work with

$template = new Stamp(Stamp::load('full/path/to/tpl/file.tpl'));

$output = '';

foreach($data as $item)

{

$output .= $template->copy('item_region')->replace('title', $item['title'])->replace('src', $item['src'])->replace('subtext', $item['subtext']);

}

return $output;

?>

Controllers: In our bigger products, these classes are solely responsible for managing the current state of the application, specifically what the end user is requesting. For example, our channel partners all have access to a management interface that allows them to manage the members of their channel, appearance of their channel page, and content that gets published to their channel. For a product this size, a custom page template acts only as the controller, determining the what is being requested and the authorization level of the current user, then implementing the correct helper to render the appropriate view with the appropriate data. A short snippet of a controller might look like this:

if ($_GET['display'] == 'normal') and $user_is_cleared)

{

$helper = new HelperClass();

echo $helper->generate_normal_output();

}

WordPress is an awesome platform for rapid development of a wide variety of content management functionality, and it’s super friendly to beginners (it’s how I got into web development.) The ease with which it allows you to create is both a blessing and a curse, since as you build larger and larger scale projects, skipping over certain (seemingly unnecessary) best practices early on leads to unmaintainable code later. I’m grateful to Michael Weichert and Elia Sarti, the great developers I was fortunate to learn from during my days at Photocrati, and glad to have brought some of their knowledge to Streetwise. We’ve found this strategy thus far to be invaluable in allowing us to build complex features in such a way that enhancements and fixes are generally possible in less than 20 lines of code, which means we can get done with maintenance quickly and focus on the fun part, new stuff.

Got your own tricks for taming your WordPress code? Let us know in the comments.

from BostInno http://bostinno.com/all-series/implementing-a-loose-mvc-structure-within-word...

Mass Senate Race: Elizabeth Warren More Reliant on Out-of-State Donors, Scott Brown More Reliant on PACs

Via ThinkProgress

Elizabeth Warren, the Harvard Law Professor and consumer advocate running for U.S. Senate against Senator Scott Brown, raised a whopping $5.7 million in the fourth quarter of 2011. But a full 69% of it came from out-of-state supporters, according to her campaign.

By contrast, Senator Brown raised $3.2 million, with 66% of reported contributions from in state, according to The Boston Globe.*

But as the AP reports, Brown is more reliant on political action committees (PACs) than Warren, having collected ten times the amount from PACs that Warren has.

Moreover, the two candidates have received support from very different PACs:

The PACs backing Brown included financial institutions, defense contractors and corporations like Citigroup, Raytheon, Lockheed Martin, McDonald’s, Microsoft and Google.

Many of the PACs supporting Warren represent labor unions, including the Sheet Metal Workers International Association, the Laborer’s International Union and the American Federation of Government Employees.

Brown and Warren have struck an agreement to curb the influence of so called “SuperPACs”, a new kind of fundraising organization made legal by a court case in 2010 and able to raise and spend unlimited amounts to influence campaigns.

The influx of outside dollars into the Mass. Senate race just goes to highlight its importance on the national scene. Polling is close between the two candidates (while Warren is the presumed Democratic nominee, she still has to win the primary). And Democrats see Brown as vulnerable in this election and hope to take back the seat that until 2010 belonged to the late Ted Kennedy.

*Contributions under $200 are not subject to the same reporting requirements, so the 66% applies to the $1.5 million of reported contributions only.

from BostInno http://bostinno.com/2012/02/14/mass-senate-race-elizabeth-warren-more-reliant...

Hashtag Marketing: 9 Ways to Avert Disaster


David Berkowitz is vice president of emerging media for digital marketing agency 360i, where he develops social media and mobile programs for marketers spanning the media & entertainment, retail, travel, and CPG industries.

Marketers creating campaigns centered on hashtags need to be cautious. Hashtags can easily turn into flashing targets that scream, “Hijack this brand!” In the past few weeks, McDonald’s launched a hashtag campaign that was promptly hamburgled, and then Research In Motion’s #BeBold campaign was similarly brandjacked.

Fortunately, there’s a way to avoid these types of situations. Hashtag campaigns happen all the time without any press coverage, usually because there’s no horror story. Here are nine ways to prevent your brand from winding up in a story about social media mishaps.


1. Figure Out Why You’re Using Hashtag


Brands tend to use hashtags, predominantly on Twitter and sometimes other services like Instagram, either to create a centralized discussion around their campaign or event, or to jump into conversations that are already happening. Assess what you want to get out of the hashtag before diving in.


2. Be Upfront About the Risk


No matter how good your intentions are and how well you execute the campaign, hashtags can get hijacked in unexpected ways. Make sure any relevant brand managers, agency account executives, and other relevant parties are aware of what can happen, and share some real examples like those noted above. Also be clear that brands use hashtags in campaigns every day, and there are very few that generate any negative publicity.


3. Determine What Kind of Hashtag Makes Sense for Your Goals


Branded hashtags like #McDstories are very transparent and often descriptive, but they might turn off people who don’t want to include that brand in their messages. They also can give brand haters more motivation to upend the hashtag’s meaning.

Generic hashtags like RIM’s #BeBold have more creative potential both for the brand and for consumers, but the hashtags can be brand-jacked just as easily, especially if the brand isn’t perceived as a match for the tag. Either way, the hashtag should be informative and concise rather than conceptual. You only have a few characters; make them count, and don’t make consumers think too hard.


4. Be True to Your Brand


Jeff Bezos once said, “Your brand is what people say about you when you’re not in the room.” What do people really say about your brand? If you’re a fast food burger chain, having salad on the menu wouldn’t justify a #BeHealthy campaign. Airlines shouldn’t try using #ComfortingThoughts unless their coach seats are really more comfortable than a typical passenger’s living room sofa.


5. Think of the Worst-Case Hijacking Scenario


Then share it with some of your snarky and cynical colleagues. Does it hold up? Would more conservative brand managers be comfortable with it? If it’s too easy to hijack and the brand bashing is too harsh, this is a good time to come up with other ideas.


6. Avoid Piggybacking on Humorous or Risqué Hashtags


Very few brands can credibly contribute to conversations around tags like “#ThingsWomenWant” or “#WorstMondayEver.”


7. Have Your Crisis Plan Ready, With Key Members on Speed Dial


No matter how cautious you think you are, people can be pleasantly unpredictable, even if that can create the occasional unpleasant experience for brands. Make sure it’s absolutely clear what everyone’s roles are should an unfortunate event happen.


8. Monitor the Campaign Religiously


It should also be clear upfront when determining everyone’s roles and responsibilities. When creating an original hashtag that hasn’t been used before, hashtags can simplify reporting on buzz generated, as community managers and analysts can view all relevant tweets in one shot.

9. Spring Into Action


If you wind up in a snafu, be ready to do whatever you can to stop the bleeding, such as ceasing any media support, engaging consumers to steer the conversation back to the original idea, or perhaps taking it on the chin and acknowledging when consumers are right. McDonald’s realized, for instance, that by pulling its Twitter ad, negative comments using the hashtag stopped almost immediately.

Brands shouldn’t overreact to the potential downfall of using hashtags, but marketers need to accept that there will always be a risk when using them. Many more marketers will choose to accept that risk. Twitter’s only growing, and hashtags are a fundamental element of Instagram, Tumblr, and other services. Brands can learn from their peers who tried to #BeBold before them, some more successfully than others.

Image courtesy of iStockphoto, tumpikuja

More About: Business, contributor, features, hashtags, Marketing, Social Media, Twitter

For more Business coverage:

from Mashable! http://mashable.com/2012/02/14/hashtag-marketing-disaster-tips/?utm_source=fe...

Television Next In Line For Industry-Wide Shakeup?

New submitter pjlehtim writes "In a recent interview. Samsung's AV product manager, Chris Moseley, said, 'TVs are ultimately about picture quality. ... and there is no way that anyone, new or old, can come along this year or next year and beat us on picture quality.' Sounds familiar? There must be a change in the perceived role of television in the entertainment ecosystem before the general public starts to care about the smart TVs manufacturers are trying to push. That change is likely to come from outside the traditional home entertainment industry. It's not about technology; it is about user experience, again."

Share on Google+

Read more of this story at Slashdot.

from Slashdot http://entertainment.slashdot.org/story/12/02/14/2144217/television-next-in-l...

Time Warner Cable's TWC TV launches for PC, brings live TV streaming to the desktop

After expanding its live TV streaming from iPads to iPhones, Time Warner Cable is going in the other direction and offering the service on PCs. The PC version of TWC TV launched today in beta -- still no word on streaming to Android devices or HDTVs yet -- but the Silverlight player will work on Windows and OS X, in Internet Explorer, Firefox, Safari or Chrome. According to the official blog it has more than just streaming, with remote control over compatible set-top boxes and DVR scheduling also included. Of course, the same restrictions still apply here as they have on tablets and phones, with playback only while connected to your home network. If you're a Time Warner customer, hit the link below to sign in and try it out, or hit the blog for more details on what works where.

Time Warner Cable's TWC TV launches for PC, brings live TV streaming to the desktop originally appeared on Engadget on Tue, 14 Feb 2012 17:47:00 EDT. Please see our terms for use of feeds.

Permalink   |  sourceTW Cable Untangled, TWC TV (beta)  | Email this | Comments

from Engadget http://www.engadget.com/2012/02/14/time-warner-cables-twc-tv-launches-for-pc-...

Tech’s Next Bubble: Where Will It Come From? [VIDEO]

John Frankel is the head of FF Ventures, an early-stage venture capital firm that includes some of the web’s hottest startups in its portfolio, including Hashable, Klout and IndieGoGo.

Check out our interview with Frankel to learn what motivates him as an investor, why he’s so attracted to early stage companies and his thoughts on where the next tech bubble will manifest.

This Venture Studio Classic was originally released on October 24, 2011.

Follow Venture Studio, in association with Mashable. The show is hosted by Dave Lerner, a 3x entrepreneur and angel investor. To join Venture Studio’s Facebook page, click here.


More Recent Episodes of Venture Studio:


More About: bubble, investing, mashable video, Startups, Venture, venture capital, venture studio, Video

For more Business coverage:

from Mashable! http://mashable.com/2012/02/14/frankel-video/?utm_source=feedburner&utm_mediu...

A Choir of Angel Investors Sing Different Parts

We at NextView Ventures often invest in a startup’s first round alongside other funds; either seed stage focused ones like ourselves or larger traditional firms.  Just as often, however, we’re investing alongside individual angel investors who are participating in the round as well.  Angel investors come in many shapes and sizes, however.  And it’s not always easy to recognize the pros and cons of taking money from individual investors, or how to even seek them out in the first place.  Addressing both of those issues can stem from the motivations as to why someone would want to put their hard-earned cash into a risky early-stage startup in the first place.   Along those lines, the world of individual angel investors is easier for entrepreneurs to navigate when you can recognize the category which he falls into based on their incentives and actions.  The choir of angel investors out there is comprised of a number of players which sing different parts:

  • The Super Angel.  Much has been written about this category, so I won’t belabor the description beyond that the defining characteristic is the large number of investments that he makes.  PROs of taking his angel money are the feeder system to venture financing of the next round and the vast network of portfolio CEOs which can be tapped into for connections and help.  CONS of an investment from a Super Angel include potential lack of “value add” because his time is spread so thin amongst many portfolio companies.
  • The Domain Angel.  Investors in this category are usually operating executives who have spent their entire careers in a specific industry vertical, like internet travel, for example.   They will have the ability to “see” the opportunity that the startup is going after unlike anyone else, save the entrepreneur because they inherently get the space.  PROS: Industry-insider who serves as a validator for the rest of the investment syndicate, extremely helpful advice and network connections.  CONS: May be more proactive in “offering” advice that is uninvited.
  • The Previous-Colleague Angel.  Having someone who the entrepreneur(ial team) has worked with before can be a good validator to other syndicate investors and future investors that they all work well together.  PROS: Nice signal value.  CONS: Potentially not much value-add beyond initial financing round.
  • The Friends & Family Angel.   These are the proverbial first-commit investors.  PROS: Known quantities who are usually the first people to be willing to write a check.  CONS: No value-add subsequently, and can potentially needlessly interject into operations or future financings that are destructive for the company.
  • The Grouped  Angels.  Especially here on the East Coast, angel investors have formally grouped themselves together for various reasons.  This can benefit entrepreneurs because of a one-pitch-many-investors process, but can be challenging too.  Elaborating on both the pros and cons here are probably the topic of another post.
  • The Fellow-Entrepreneur Angel.  Entrepreneurs know other entrepreneurial endeavors best, and can be great backers of other businesses – they’re likely to be one of the first to take the leap of faith and the first to help, which are just two of the PROS.   CONS:  depending on the size of their previous wins, they may not have a large checkbook; if the relationship is more of a peer than an advisor, they may not be constructively critical.
  • The “True Believer” Angel.  These angels are can as difficult to find as a diamond in the rough, but there are those angels out there who hear startup’s story, instantly believe, and want to immediately invest sometimes in spite of the financial risks.  PROS: Over-the-top encouragement and support, a cheerleader as a balancing voice amongst what-have-you-done-for-me-lately investor syndicates.  CONS: Lack critical eye and challenge to push an entrepreneur after the investment has closed.
  • The Financial Angel.  There is a small cadre of angels out there who are diligently and intentionally, but also quietly, building a diverse of early stage startup investments through the lens of a portfolio allocation model.  Rather than investing in a fund manager to do the work for them, they are instead doing it themselves for the purposes of disbursing their personal capital into a portfolio purely aimed at financial return.   PROS: Validation for other financially-savvy syndicate investors, lack of intrusion to let the entrepreneur run his own business.  CONS: often very little help or involvement with the company post-investment, if at all.
  • The “Sport Fisherman” Angel.  These mega-wealthy individuals, sometimes not from the startup world, invest an extremely small portion of their net wealth into early-stage startups so that they have something to talk about with their friends at cocktail parties.  They do it merely for the entertainment-value of participating and care very little if their investments actually yield a return (though that would make for even better conversation fodder).  PROS: Sometimes these individuals are well-connected or have a public persona which could be helpful to the business.  CONS: Potential lack of concern for the entrepreneur or the company, as there is always another fish to try to catch.
  • The Foolish Angel.  Often bucketed with others above into a “Friends, Family, & Fools” category, I think that the truly naïve blind supporter angel deserves his own category.  PROS: Money is money.  CONS:  Many, as a foolish owner of your business can influence it in foolish ways.

If, as an entrepreneur, you’re currently seeking and pitching angel investors, and he doesn’t fit into one of the above categories, then there’s a good chance it’s going to be tough to get him over the line and commit to writing a check.  All of the people in the above categories have their own different motivations, but they at least have those as drivers towards investing.  Without a specific rationale, it’s an uphill battle to convince an angel investor part with his own personal capital.

Conversely, when starting a financing process which includes raising money from individual angels, using the above schema as a guide to thinking about who within your network (and your network’s network) might be interested in participating as an early investor is a good first step.

At the end of the day, all money is green.  But if you have the fortunate ability to be oversubscribed in a seed round and are selecting who you are going to let into limited space within the round, it’s important to think about composing a syndicate of angel investors which come from a deliberate range of the above categories so that you can maximize the benefits and hopefully diffuse some of the potential drawbacks.  Here at NextView, we welcome investing alongside individual angels, especially when they’re going to be constructive in some way.  A vast majority of the seed rounds in our portfolio have angel participation; and as my partner Rob explained in a recent overview, a third of our initial investments are syndicates comprised of just the NextView Ventures fund plus individual angel investors.

from BostInno http://bostinno.com/channels/a-choir-of-angel-investors-sing-different-parts/

20 TV Shows With the Most Social Media Buzz This Week [CHART]

Not to give away the farm, but I bet you can guess what television event topped the charts in terms of social media chatter this week. Hint: According to Trendrr, the broadcast is the second highest social TV event on its records, after the Super Bowl, of course.

By golly, you guessed it. Sunday night’s Grammy Awards gained nearly 19 million social media activities over the past week. The event logged 17,122,439 social media mentions yesterday alone, superseded only by the Super Bowl’s 17,487,241. Compare the Grammys to 2011′s MTV Video Music Awards, which received only 5,567,954 social media mentions, and you’ll understand the growing influence of social TV.

According to Trendrr, the Grammys moment with the highest social media activity was Adele’s performance, which earned a standing ovation and deafening applause from the Staples Center crowd. Apparently, today’s social channels saw the equivalent.

Apart from the red carpet, viewers buzzed about the presidential election and cartoons galore (four different animated shows made the cut). D’oh!

The data below is compliments of our friends at Trendrr, who measure specific TV show activity (mentions, likes, checkins) across Twitter, Facebook, GetGlue and Miso. To see daily rankings, check out Trendrr.TV.


Image courtesy of iStockphoto, narvikk

More About: features, Social Media, social tv, social tv charts, Trendrr, TV

For more Entertainment coverage:

from Mashable! http://mashable.com/2012/02/13/social-tv-chart-2-13/?utm_source=feedburner&ut...

Bluefin Labs: Grammy Awards Top Super Bowl XLVI for Social TV Record [Infographic]

People don’t just watch television anymore. We’ve now got our laptops, tablets and phones in our laps so we can keep up with our favorite social media pundits (and chime in ourselves) to make watching TV alone at home a truly social experience.

Boston based Bluefin Labs found that social TV has had its most active nights to date in the past two weeks. Super Bowl XLVI enticed people to leave 12.2 million social media comments about the game. I abstained because it hurts to type when you’ve chewed your fingernails off in anticipation.  And then, just a week later, the Grammy Awards trumped the record set by those who watched the second worst Super Bowl ever. Thirteen million comments were made about the 54th annual ceremony, which represents a 2,280% increase from the year before.

I myself was wondering about whether Rhianna was hoping Chris Brown would tumble down that stair contraption thing while he was dancing and apparently, so were a lot of other people.

According to Bluefin’s website, “the first big spike in responses occurred when Chris Brown took the stage, though much of the sentiment was negative and related to past domestic abuse issues.”

I’m also learning, literally right now as I write this, that Paul McCartney performed with the Foo Fighters and Bruce Springsteen and now I’m furious that I went to bed when I did. The Boss, the Walrus and the Foo sharing the stage! Gaht dayumn. Now social media just needs to figure out how to wake me up when stuff that matters is happening.

Below there is a cool infographic put together by Bluefin with some more details and how the award ceremony stacks up to previous entertainment events.

Unrelated sort of, but I was glad to see Bon Iver win the award for best new artist. Homeboy can play.

from BostInno http://bostinno.com/2012/02/13/bluefin-labs-grammy-awards-top-super-bowl-xlvi...

Internet crackdown in Iran continues, but Tor users are all back online

Tor usage in Iran has made a full recovery days after the Iranian government started blocking encrypted Internet traffic.

Last Friday, the number of Iranian users connecting to the Internet through Tor's anonymizing network had plummeted from roughly 50,000 per day to nearly zero. By Sunday, however, Tor usage was back to normal and expected usage levels, according to updated metrics provided by the Tor Project.

In response to Iranian censorship, Tor Project leaders rolled out a new obfuscated bridge that allows Iranians to circumvent the blockages and connect to the Internet through Tor once again. It's unclear if the recovery in Internet connections is due primarily to steps taken by Tor and its users, but the government's latest censorship program does not appear to have ended.

Reuters wrote on Tuesday that "millions of Iranians have suffered serious disruption recently in accessing e-mail and Internet social networking sites, raising concerns authorities are stepping up censorship of opposition supporters ahead of parliamentary elections next month." Parliamentary elections are scheduled for March 2. Additionally, Google confirmed to Bloomberg on Monday that its services, including search, Gmail, and YouTube, had been blocked in Iran since Friday. We've asked Google for an update on the situation and will provide more details as we get them.

Read the comments on this post

from Ars Technica http://arstechnica.com/tech-policy/news/2012/02/internet-crackdown-in-iran-co...