CycloneOS

Internet Solutions

Adding or Editing Products in WooCommerce via XML-RPC

I was recently tasked with connecting an external inventory control system with WooCommerce. In this environment, the ICS is the main repository and WooCommerce is just a customer portal.

After researching the WooCommerce API, I quickly found that it only supports read access for the most part. I then tried connecting through the Jetpack REST API but that had it’s own set of issues and design limitations.

[ Edit: Woocommerce has updated their REST API since this article was written and it now appears to support most post functions. ]

Finally, I decided on the standard WordPress XML-RPC API. It may be less secure, but at least it works and since it only has to accept data from a single source, a firewall rule will help with security.

Here are some quick notes that caused me some difficulty in an otherwise simple setup.

Custom fields (meta fields) are stored in an array of arrays when preparing the data to send.

$custom_fields = array(
                array('key' => '_sku', 'value' => '001abc'),
                array('key' => '_price', 'value' => '1000')
            )

 

Any meta fields starting with an underscore are considered protected and can not be edited through XMLRPC without changing some default behavior.

 You can add this code to your functions.php or plugin as needed:

 

function _meta_sanitize_cb ( $meta_value, $meta_key, $meta_type ) {
    return $meta_value;
}
	
function _meta_yes_you_can( $can, $key, $post_id, $user_id, $cap, $caps ) {
    return true;
}

function test_register_meta() {
    register_meta( 'post', '_sku', '_meta_sanitize_cb', '_meta_yes_you_can');
    register_meta( 'post', '_price', '_meta_sanitize_cb', '_meta_yes_you_can');
}
add_action( 'init', 'test_register_meta' );

 

How to change the background color in the header of Twenty Thirteen theme

I see this question a lot in the forums but since I like to troll them without registering (I hate email spam) I am posting the answer here.

This is for the WordPress Twenty Thirteen (2013) theme.

.site-header {

background-color: #FFF;
}

(Note: change the #FFF to whichever html color code you want)

Now, if you aren’t sure what to do with that code, there are two main options.

  1. Create a child theme and add it to the style.css file.  You can read how and why you should use child themes here.
  2. Use a custom css plugin and add it to it’s css area.  I like jetpack since it has a bunch of useful modules but there are plenty others if you’re not a jetpack fan.

If you haven’t tried twenty thirteen yet, you should give it a look.  It’s simple and responsive.

Why Use WordPress as a CMS?

WordPress is a viable option for a Content Management System (CMS). It is easy to use and the tool is extremely cost-effective. WordPress can help you build your site and then manage it simply and at a low cost. Word Press is an extremely popular blogging tool and CMS for a number of reasons. Over time, WordPress is developing more features to cater to the CMS market, so the tool will become even more robust over time.

A CMS is software that helps users organize and manage their web content. Most CMS tools, such as WordPress, are designed with the non-technical user in mind. A CMS can make the process of updating a website fast and simple. There are a variety of CMS tools out there. Some can be custom-built and extremely expensive, but WordPress provides a low-cost option. Although WordPress was originally created as a blogging tool, it can also work as a CMS. If you have a minimal technical budget, WordPress is an ideal tool for your company.

Most users need a CMS to manage pages, posts and links. Pages are the stable content on your website. They don’t typically need to be updated in real-time. Most users access them through the menu features on your website. Posts are often blog entries or articles. They are time-sensitive content. They need to be on your site as soon as possible to keep it fresh, up to date and interesting. Links refer users to other sites. These may be used to point users to research or other interesting content.

WordPress has effective page management features. It also allows users to upload and manage media, with is an import part of content management, especially when it comes to posting. It’s easy to add links and manage the themes of websites. This corresponds with the common needs users have when it comes to a CMS. WordPress can be adjusted to create custom post and page types for different types of content.

WordPress has plug-in architecture. It also has a template system. The tool can be set up for non-technical users so that they can enter content simply. WordPress makes blogging simple and you can easily update your website with the tool. Plug-ins provide several advantages. They can add features such as navigation bars or widgets. Some plug-ins help you optimize your site’s speed. Others provide content display features which can be an advantage for a CMS. The advantage of plug-ins is that they easily add functionality without the need for complex programming. However, with in-depth knowledge of HTML and CSS is necessary for updating plug-ins and other features of the site.

In order for WordPress to be an effective CMS, the architecture of the site must be carefully thought out. The site builder needs to understand the user needs when it comes to building the WordPress CMS. The builder should be familiar with the technical capabilities of the people that will commonly use the site. They will also need an understanding of what the company’s needs are in terms of content management. There aren’t one-size-fits all solutions when it comes to a WordPress CMS. The design and structure of the website need to be customized to fit the company’s specific situation.

WordPress changes frequently. Any sites that are built with the tool will need updates and adjustments over time. Plug-ins need to be updated and site features may need to be adjusted to fit WordPress updates. It requires some technical knowledge to keep the CMS in its ideal usable condition over time.

The Benefits of SEO

SEO stands for Search Engine Optimization. SERP stands for Search Engine Results Page which is the list of web pages that are returned by a search engine in response to a keyword search. Understanding these terms and how they affect your business and website is key to maximizing the effectiveness of your internet presence.

There are three kinds of SERPs. The first kind of listings are those that are indexed by the search engine. Next are listings that are indexed into the search engine by person. The final kind are paid listings which are listed on the search engine for a fee. When users search for information on the site, the search engine, such as Google or Bing, will return a long list of results.

Why should you care about SERP? When users search for something on the internet, they want to find the best possible resource as quickly as possible. You want your webpage listing to be high on the list of results. It is like being the first restaurant or gas station off of a highway exit. These businesses will get much more traffic because of their location. The higher you’re your page is ranked, the more traffic you will get from potential customers. While is possible to attract visitors when your site is lower on the list of webpages, it is easier to attract more traffic when you are at the top of the list.

Understand SEO and SERP is critical to making the most of your marketing efforts. Many websites use SEO techniques to improve their SERP rankings. To have an effective SEO campaign it’s important to understand keywords and how they relate to your business. When users are searching for a topic, they enter particular keywords in a search engine to find information. These keywords vary by topic. For example, if users are looking for home remodeling services, they may enter terms like construction, house painting or drywall.

It’s important to have valuable links to your site. You want to attract site visitors that need the products and services you provide. Effective SEO strategies involve understanding how your customers search for information and how your competitors use keywords to your advantage. First, you should evaluate competitors to understand what keywords they are using and how these keywords affect their rankings. Are they highly ranked for keywords that will work for your site? Are they using keywords that you haven’t considered? Research your competitors thoroughly so you can apply relevant strategies to your site

Next, you need to understand the terms that customers use to search for your type of website. You can evaluate the words and phrases that typically lead visitors to your site. This is a good indication of which keywords you should focus on. Keep in mind that the best keywords for your site may change over time. Your SEO strategy needs to be evaluated regularly to ensure that it is producing results.

Your next step in creating an effective SEO and SERP strategy is preparing good content. You cannot create useless content that is simply filled with repeated keywords. This is called “keyword loading” and most search engines are smart enough to avoid sites that do this. Instead, you need to create quality articles and marketing materials that contain keywords. The content should contain at least 250 words. The keywords should be added into the content in limited amounts. You can analyze the percentage of keywords in your content. Typically, the keyword presence should be around 1.5% to 3% to yield the best results from search engines.

JetPack and Artisteer CSS Problem – scroll bars around social media icons

If you are using a WordPress theme created with Artisteer you may see scroll bars around the Share This social network buttons from the JetPack plugin. Luckily, jetpack provides an easy place to override css so you can paste the following code in to the css editor to get rid of the scroll bars.

.art-postcontent .sharedaddy ul > li:before, .art-post .sharedaddy ul > li:before, .art-textblock .sharedaddy ul > li:before { margin: 0; }

 

We have tested this with WordPress 3.6, 3.61 and Jetpack 2.4.1 – 2.5

Remember to use the Jetpack CSS editor under Appearance -> Edit CSS and not the WordPress editor.  The Jetpack editor will allow you to easily revert the change if it happens to conflict with something else on your site.

What is a CMS?

A Content Management System (CMS) is a computer program that allows users to publish, edit and modify content. A CMS is important to the success of a website. The CMS will help you create, add and keep track of the content you create for your site over time. Without a CMS, it is difficult to keep track of what information has been on your site and when. You’ll have trouble tracking down the content you’ve published on your site and the changes that have been made on your site.

A CMS makes it simple for non-technical people to add and edit content. They can also manage their website if the CMS is set up properly. A CMS can be designed so that users don’t need programming skills to manage their content. However, to optimize the website, a programmer may need to set up the CMS and update it on a regular basis.

A good CMS will perform several functions “behind the scenes” that support users’ efforts. The CMS will provide navigation elements. It will make the content searchable and provide indexing. The CMS monitors users and controls their permissions and security settings. The CMS will also help users update both real-time and static content. The real-time content generally consists of blogs, articles and other information that you want the readers to have access to immediately. Static content is information that is accessed through tags or links on the website. This content does not change often.

The CMS should be designed to naturally flow with the type of information on your site. The CMS will determine which pages go where. It also determines which pages are linked together. Modern CMS systems give users a web-based authoring environment. This allows users to update the site remotely if necessary. This allows your company to have more than one author for the site. For example, a technical writer can update the content that is targeted towards technology. Marketing writers can update the sites sales and marketing information. Your site can have multiple authors who have specialized writing skills.

The CMS can dramatically simplify your workflow. For example, a writer can create a new post for the site and send it to his or her manager for review and approval. Then, the manager can request an editor to review the post. They could also ask the marketing, financial or legal department to review the post. Once the reviewers approve the post, it can be published immediately.

Many websites such as blogs, shopping and news sites are run by a CMS. In addition, corporate and marketing websites usually have a CMS. The purpose of the CMS is to display content such as articles, links and media on the website. A CMS can be simple with minimal features or more complex, depending on the company’s needs.

One advantage of a CMS is that it allows users to upload links and media quickly and simply. Many people want to add links for customers that refer them to helpful information that it hosted on other sites. This may include articles, vendor information or other useful information. Adding media to a site keeps it interesting and fresh. It allows users to add information like tutorials, product demonstrations and marketing presentations.

There are many other benefits to a CMS. If it is set up properly, it can protect the security of your company and your users. This is especially important if you have an ecommerce site. The CMS will make it easier for end users to navigate through your site and find the information that they needs. A CMS makes decentralized authoring possible. Writers can add information to the site from mobile sites and several computers. A CMS allows for rapid turn-around time and allows your site to be flexible.

Remove NULL or empty values from a PHP array

I found this simple code while searching. To remove emtpy ( “” ) values and NULL values:

$new_array_without_nulls =($array_with_nulls);

To remove only NULL values but ignore empty strings, etc:

$new_array_without_nulls = array_filter($array_with_nulls, 'strlen');

Credit goes to Brian Cray for the original post.

Monitoring MySQL Queries

  mySQL command line client   SHOW VARIABLES LIKE “general_log%”; SET GLOBAL general_log = ‘ON';