How to change the ‘Enter title here’ text in WordPress dynamically.

I am using the Pods Framework to developing a Content Management System (CMS) for a client. With Pods Framework plugin installed in WordPress, it’s possible to create Custom Content Types and Custom Fields. Usually this involves writing the PHP that you need by hand. With Pods, you can create all of the Custom Content Types and Custom Fields that you need from within the Pods plugin.

While developing the CMS I ran into a small issue. WordPress automatically displays ‘Enter title here’ text in the title field of any Post or Custom Content Types. When you create a new Post or Custom Content Type Pods does not correct this text to suit the Custom Content Type. Which is fine when the new Post is a Post. However lets say you are creating a CMS for a site storing customer information and the title field is being used for the Customers name then the ‘Enter title here’ is less useful and could be confusing to some.

Enter title hereI searched the internet looking for a solution to this problem. There were several approaches but where they all fell down was that they relied on a if/then statement for each Post, Page, or Custom Content Type. Which in its self is not a problem however every time you add a new Custom Content Type you have to add a new if/then statement. What I wanted was the replacement text to be created dynamically so that the function worked in all cases. So I wrote a function that will do exactly that.

Add New Customer HereThe best part is all you have to do is copy the text below and past it in to the functions.php file of your child theme and it is done. From then on the ‘Enter title here’ text will be dynamically replaced through WordPress with something like ‘Add New Customer Here’

Functions.php
function change_default_title( $title ){
     global $post;
     $enter_title_text = esc_html( get_admin_page_title() ).’ Here';
     return $enter_title_text;
}
 
add_filter( ‘enter_title_here’, ‘change_default_title’ );

Cron update after upgrading to Ubuntu 14.04.

After a recent upgrade from Ubuntu 12.04 to Ubuntu 14.04 I started to receive the email below. This email was being sent out by the cron system on a daily basis because the developers of Ubuntu are trying to make Ubuntu even more secure.

eMail

From:  root@myserver.com
Subject:   Cron <root@myserver> test -x /usr/sbin/anacron || ( cd / && run-parts –report /etc/cron.daily )
To:    root@myserver.com

/etc/cron.daily/logrotate:

error: skipping “/var/log/apache2/access.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/apache2/error.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/apache2/other_vhosts_access.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/apache2/suexec.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/apport.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/aptitude” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/dpkg.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/alternatives.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/fail2ban.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/mysql.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/ppp-connect-errors” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/razor-agent.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/rkhunter.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/syslog” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/mail.info” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/mail.warn” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/mail.err” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/mail.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/daemon.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/kern.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/auth.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/user.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/lpr.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/cron.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/debug” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/messages” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/ufw.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/wtmp” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/btmp” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/named/security.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping “/var/log/procmail.log” because parent directory has insecure permissions (It’s world writable or writable by group which is not “root”) Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

run-parts: /etc/cron.daily/logrotate exited with return code 1

 

The important part is of all of those statements in the email is

 

Set 'su'
Set “su” directive in config file to tell logrotate which user/group should be used for rotation.

 

which means the “su” directive in the logrotate config file located at ‘/etc/logrotate.conf’ has not been set. As a consequence none of the logs mentioned in the email could be rotated. Log files need to be rotated at least once a day or they will bloat and eventually fill the entire hard drive.

The fix is really very simple. Open the file ‘/etc/logrotate.conf’ with your favourite text editor and add a few blank lines in the conf file just after

 

# see “man logrotate” for details
# rotate log files weekly
weekly

 

then copy the three lines of code below.

 

Add this code
# use the syslog group by default, since this is the owning group
# of /var/log/syslog.
su root syslog

 

and paste them in between the blank lines you just created. Don’t forget to save the file. Now the top of your ‘/etc/logrotate.conf’ should look like.

 

‘/etc/logrotate.conf’

# see “man logrotate” for details
# rotate log files weekly
weekly

# use the syslog group by default, since this is the owning group
# of /var/log/syslog.
su root syslog

# keep 4 weeks worth of backlogs
rotate 4

 

That is it the next time your cron system runs all of those logs will be rotated automatically for you.

Developing a website

Developing a website is a great way to quantify your business. In many ways developing a website is the same as developing a business plan with out all those annoying figures. During the process of developing a website you will need to work closely with your web developer to identify and quantify exactly what your business does. So that your website will reflect what your business is actually about and present what you do to your visitors in the most professional manner.

dauntingTo most business owners this process sounds daunting. However it can be an extremely liberating process because if you devote yourself to the process and you have an experienced web developer you will not only wind up with a professional website, you will also be clear about the direction your business is heading.

To help you get your new website up and running as quickly as possible spend some time thinking about and where possible write your responses to the list of questions below. To assist in the process of developing a website at Binaryone we provide a free 1 hour consultation to get you started. Use our contact page to send us a message and we will arrange a time for your free consultation.

Website questions
1.    Is this a new site or a redesign of an existing site?
    a.    New
    b.    Redesign
        i.    What is the purpose of the redesign?
        ii.    Are there current specific issues with the current site you hope to improve or correct?
        iii.    What is the web address of your current website?
        iv.    What do you like and dislike about your current system?
        v.    What audience needs does your existing site do a good job fulfilling?
        vi.    What audience needs aren’t being met by your current site?
        vii.    Where does it fall short?

2.     In short, what does your organization do?

3.    Who is your organization’s target market?

4.    Describe the concept, project or services this site is intended to provide or promote.

5.    Who will Binaryone be working with to guide this project to completion?

6.    How many people at your organization will be involved with the project?

7.    Who is responsible for making the final decisions?

8.    Who will be responsible for maintaining the site after launch for content and technical matters?

9.    To the best of your ability, describe the various groups that will use the site. What are they hoping to accomplish? EG:
    a.    Prospects seeking information about our company.
    b.    Customers who might purchase our product.
    c.    Customers looking for menu, hours and location information.
    d.    Donors who might contribute to our organization.

10.    What are the general demographics of your audience (or site visitors)?

11.    For the purposes of this site, which of these groups is the primary audience (the one you’d consider most important?) This can be difficult to identify, but it’s important to determine who the primary audience should be.

12.    What primary action do you want your primary audience to take when visiting your site?
    a.    Fill in a contact form.
    b.    Ask for a quote.
    c.    Call you.
    d.    Find out where you are located.
    e.    Purchase a product,
    f.    Sign up for a newsletter.
    g.    follow you on social media.

13.    Describe in as few sentences the feelings you wish your site to evoke in your visitors.

14.     Describe in as few sentences the brand attributes you want your site to convey.

15.    Using adjectives and short phrases, describe the site’s desired look and feel. Examples:
    a.    Easy to look at,
    b.    edgy,
    c.    classic,
    d.    up-to-date,
    e.    crisp,
    f.    modern,
    g.    traditional,
    h.    understated, etc.

16.    Do you have a visual identity that you are happy with (including brand identity and logo) or is that something you need designed or evolved?

17.    List around three competitors sites.

18.    Also what you consider their strengths and weaknesses?

19.    What differentiates your product, services or ideas from your competition?

20.    Approximately how many pages do you think you will need on the site?

21.    What features would you like to be included on the site? Examples include:
    a.    Ads/Billboards
    b.    Blog
    c.    Community Forum
    d.    Company News
    e.    Custom Page Not Found Page
    f.    Customer Lead Form
    g.    Event Calendar
    h.    Google Map(s)
    i.    Mailing List Integration
    j.    Member/Staff Protected area
    k.    Multiple Location Listings
    l.    Online Payment/Donation
    m.    Photo Gallery
    n.    Podcasting
    o.    Selling Products or Services (Ecommerce)
    p.    Social Media Integration
    q.    Staff Listing
    r.    Testimonials
    s.    Videos

22.    Are there any third-party integration points we need to know about? Examples:
    a.    Interfaces to a CRM,
    b.    offsite e-commerce,
    c.    POS,
    d.    mapping solution,
    e.    social site or other use of a third party API, etc.

23.    How much of the site content is already created? Content includes:
    a.    logo,
    b.    titles,
    c.    headlines,
    d.    page text,
    e.    staff bios and pictures,
    f.    testimonials,
    g.    photos, etc.

24.    Would you like assistance with content creation?

25.    Are there any other technical requirements for the site that you haven’t mentioned so far?

Questions About Ecommerce Sites.

If you want an ecommerce site these are additional questions you should consider.

1.    Do you already know what ecommerce solution you want to use?

2.    What kinds of products will you be selling?

3.    Do you currently use third party sites for sales (like Amazon, eBay, Etsy, etc.)?

4.    Will you sell memberships or access to premium content on your site?

5.    Will your site sell downloadable products?

6.    Will your products have multiple variations? Examples include:
    a.    sizes,
    b.    colors,
    c.    materials
    d.    price points.
7.    Roughly how many products will be listed on the site?

8.    Do you want the web site to track inventory?

9.    Do you have product descriptions available?

10.    Do you have high quality photos available for each product?

11.    Do you want to allow product reviews or ratings from purchasers?

12.    Do you want to add social sharing icons to product pages?

13.    Will you offer an affiliate or referral program?

14.    Do you want to build an email list of customers for promotional purposes?

15.    Do you offer quantity discounts?

16.    Do you want to offer coupons?

17.    Do you want to offer gift cards?

18.    Do you want to offer wish lists or registries?

19.    Do you need to generate invoices or packing lists?

20.    Do you offer preferred pricing to certain groups?

21.    Will you use PayPal to process paymnets?

22.    Do you have terms of service and refund policies in place for the site?

23.    How will you handle customer service inquiries? EG: Questions About Time & Money.

Should you kill or terminate a misbehaving process.

Have you ever had a linux process that was not running but when you try to start or restart the process nothing happens. You may find that you need to kill the process before you try to restart it because the process is actually still alive and not responding or not actually alive but the pid (which is a unique identifying number that tells the kernel that the process has stated or is alive) was not removed when the process ended. So the kernel thinks that the process is working just fine when in fact it is not and won’t start it a new.

Before you kill the process you should always try to terminate it first. Because terminate tries to end the process gracefully and finish writing any remaining data that the process may have stored in memory as well terminate will finish writing any logging data to assist you to find out what caused the process to fail in the first place

The command to terminate a process is

Code
kill -15 pid

replace pid with the pid number

If your attempt to terminate the process fails then you will have to use the more powerful kill command which will bypass the process and ask the kernel to kill the misbehaving process directly.

The command to have the kernel kill a process is

Code
kill -9 pid

replace pid with the pid number

Before you can kill the process you will have to find its pid. To find out the pid of a running process in virtualmin you can go to

Webmin> System> Running Processes>

and select pid from the Display menu then scroll to find the pid of the process you are looking for. Linux, kill, terminate, kill -15 pid, kill -15, kill -9 pid, kill -9, pid, linux process, process, not running, process not running, start, restart, start or restart, not responding, process not responding, kernel, pid not removed, kill the process, stop the process, terminate the process, end the process, end the process gracefully, writing any logging data, virtualmin, webmin, Running Processes,Click on the pid of the process you want to kill and you will be taken to a new screen where you can terminate or kill the process by clicking the matching button.

Linux, kill, terminate, kill -15 pid, kill -15, kill -9 pid, kill -9, pid, linux process, process, not running, process not running, start, restart, start or restart, not responding, process not responding, kernel, pid not removed, kill the process, stop the process, terminate the process, end the process, end the process gracefully, writing any logging data, virtualmin, webmin, Running Processes,If you are not a virtualmin user you can open a terminal window and type

Code
ps aux | less

which will give you a list that looks something like

Linux, kill, terminate, kill -15 pid, kill -15, kill -9 pid, kill -9, pid, linux process, process, not running, process not running, start, restart, start or restart, not responding, process not responding, kernel, pid not removed, kill the process, stop the process, terminate the process, end the process, end the process gracefully, writing any logging data, virtualmin, webmin, Running Processes,when you have the pid you need to kill the process. As mentioned above you should always try the terminate command first. In the terminal window type

Code
kill -15 pid

replace pid with the pid number

If the process does not terminate you will the need to use the more powerful kill command

Code
kill -9 pid

replace pid with the pid number

Is My Blog Down for Everyone or Just Me Site Checker!

Have you ever tried to load your site or blog only to find it was down? Then you contact your service provider only for them to tell you that your site is up everything is running as normally. Your service provider tells you that the problem is with your connection or computer. Now you need a way to confirm what they are saying. There are a number of free  services that can check your site for you.

http://downforeveryoneorjustme.com/
http://www.checksite.us/
http://downorjust.me/

Go to either or all of these checking sites and enter your sites or blogs URL and submit it. The checking site will confirm wether or not your site is running or not and report to you.

How to copy and save an image from a flash website.

Lets say there is an Adobe Flash website with an image that you want to show to your graphic artist. This image is the type of image you are after for your website. With a normal website you could just right click on a photo and you would have the option to either copy the image or save it so you could send the image to your artist. But since it’s an Adobe Flash website, right clicking gives you two choices “Settings” and “About Adobe Flash Player” so you are unable to copy the image you so desperately want. Well there is a way to get the image you are after.

Below are the instructions for you to copy and save a flash image. Before you copy an image and use it you should consider any copyright implications. However if you are only using it as an example of the type of thing you are looking for you should not have any problems.

How to
1.    Load the site with flash that you want to get an image from.

2.    Find an image that you want and centre it on the screen, move the curser out of the way to one side or the top or bottom of the screen.

3.    Then Press the Print Screen key on the keyboard.
    a.    The Print Screen key is usually the next button to the right of F12 button, labelled something like ‘prt sc’.
        i.    What it does is copies the entire screen as it is  at the moment you press it, so make sure the cursors’ is moved away from the picture that you want.

4.    Then load MS Paint.
    a.    To find MS Paint click Start> then run your mouse over the All Programs menu item.
    b.    Then move your mouse over the Accessories menu item.
    c.    On the Accessories menu that opens click the paint menu item to run the paint program.
    d.    When the paint program loads click Edit> Paste>.
        i.    Then click the select button on the side bar.
            (1)    Usually the top right button that looks like a dotted square.
            (2)    This will allow you to draw a box around the section of the image you want to keep.
            (3)    You will have to practice to get it in the write place.
        ii.    When you have the box around the section of the image you want to keep press Ctrl and click C to copy the section of the image you want to keep.
    e.    Then still in paint, select File> New>
        i.    when asked if you want to save click no. The image will close and a new blank canvas will open.
    f.    In the new canvas select Edit> paste>
        i.    You will now have the image you want.
        ii.    Then click File> Save>
        iii.    Then select the folder you want to save the image in.

 

Have your Jetpack and use Better WP Security too

Jetpack header logoRecently I started using Jetpack for amongst other things the Publicize feature. Publicize
automatically share your site’s posts on a range of social media networks when you publish a new post. The time this saves makes Jetpack a worth while plugin on its own. Not to mention all of the other features you get when you install Jetpack.

Jetpack PublicizeAfter I installed and configured Jetpack to connect to wordpress.com and Publicize to my social media sites I published a Post and sure enough a post was sent to my social media sites. The next post which was after an update of Jetpack was not so successful. The post on my blog was fine but no publicization of my article to my social media sites. So commenced the reading, reading, reading, reading, reading, reading…

Then I came across the Jetpack Troubleshooting Tips page which states;

Jetpack Troubleshooting Tips
3. Check your XMLRPC file. You can do this by going to your web site URL and adding “/xmlrpc.php” to the end (without the quotes). When it loads in your browser, you should see “XML-RPC server accepts POST requests only.” on a line by itself.

If you see this message, but it is not on a line by itself, a theme or plugin is displaying extra characters when it shouldn’t. See points 1 and 2 above for debugging steps.If you get an 404 Error Not Found message, contact your web host. They may have security in place that is blocking XMLRPC.

4. Check the Known Issues list and make sure you aren’t using a plugin or theme listed there.

I ran the test for my self. I simply went to my home page and added “/xmlrpc.php” to the end of the URL in the address bar of my browser window (without the quotes) and sure enough I got a 404 error page, not the “XML-RPC server accepts POST requests only.” on a line by itself. So I clicked the Known Issues list link and the words Better WP Security immediately jumped off the page because I have the Better WP Security plugin installed. The Known Issues page states;

Known Issues
Known Issues
WordFence, Better WP Security, Login Security Solution

These plugins block access to your site’s XML-RPC file. This file is used by Jetpack to connect to WordPress.com, and must be accessible at all times. You will consequently need to deactivate these plugins to be able to use Jetpack.

My first thought was “I am not going to deactivate a plugin that provides the amount of security that Better WP Security provides with out first running some tests”. I then went over to my wordpress dashboard and the Better WP Security plugin and had a good look around. I had not had a look at the Better WP Security plugin for a while and did not remember all of its features.

Better WP Security - Various Security TweaksQuite quickly I found what I was looking for on the Tweaks screen which ststes;

Remove EditURI header
Remove EditURI header

Removes the RSD (Really Simple Discovery) header. If you don’t integrate your blog with external XML-RPC services such as Flickr then the “RSD” function is pretty much useless to you.

Warning: This feature is known to cause conflicts with some 3rd party application and services that may want to interact with WordPress.

Better WP Security Header TweaksI uncheck the checkbox and clicked Save Changes. Then I ran the “/xmlrpc.php” test again. This time it was successful I got “XML-RPC server accepts POST requests only.” on a line by itself.

Now to test if my posts are once again being published on social media networks I will post this Article but if it does not work I will continue searching for the answer and post it here as an addition to this post.

Google Analytics VS Awstats or Webalizer

Who will be the winner?

First things first

Analytics is the study and analysis of data that has been collected. In the case of web analytics that is easily achieved because of the extensive amount of data that is written to log files or sent to a third party server (in the case of Google Analytics) each time the server takes any relevant actions. Google Analytics block graph, Google Analytics, Analytics, Business analytics, Awstats, Webalizer, web analytics, data, Technological Approaches, collecting web analytics data, patterns of behaviour, JavaScript on each page, JavaScript, Log File Analysis, Log File, Log Files, web browser, ip address, visitors, visits, visitor behaviour, data collection, the server, the network, and bandwidth usage,
AWstats logo, Google Analytics, Analytics, Business analytics, Awstats, Webalizer, web analytics, data, Technological Approaches, collecting web analytics data, patterns of behaviour, JavaScript on each page, JavaScript, Log File Analysis, Log File, Log Files, web browser, ip address, visitors, visits, visitor behaviour, data collection, the server, the network, and bandwidth usage, The Webalizer, Google Analytics, Analytics, Business analytics, Awstats, Webalizer, web analytics, data, Technological Approaches, collecting web analytics data, patterns of behaviour, JavaScript on each page, JavaScript, Log File Analysis, Log File, Log Files, web browser, ip address, visitors, visits, visitor behaviour, data collection, the server, the network, and bandwidth usage,

 

Update wordpress – WP Maintenance Mode – Internal Server Error – solution

The problem

After updating your WordPress and/or WP Maintenance Mode plugin your site is running normally for a period of time eg between 6 and 18 hours. Then at some random time all that any visitor is able to see is an Internal Server Error message. To anyone trying to get to your site, your site appears to be broken. For more information open the section on Server Side Errors in my article, Where to find Apache response codes and how to determine their meaning.

Internal server error, Update wordpress, WordPress, WP Maintenance Mode, Maintenance Mode, Maintenance, Mode, Internal Server Error, site, broken site, Plugins, Plugin, Support

Fail2ban for the uninitiated.

What is fail2ban and why you should install it.

fail2ban_logoIn this day and age every web site owner or administrator is obsessed with improving the amount of traffic that flows to their site, even though little thought is given to weather or not, that traffic is of any use to their site or what harm it is potentially doing. Read why you need to consider who is coming to your site and what you can do to protect yourself from spammers and scammers.