WordPress is a free and open source blogging tool and a content-management system (CMS) based on PHP and MySQL.
7
votes
2answers
92 views
Recursive download articles and dump to MongoDB
This is simple code that recursively downloads articles from the public WordPress API:
...
2
votes
2answers
43 views
Saving array values for a secondary foreach loop
Although used within the WordPress platform, this is PHP focussed question.
I have an array of child posts, some have content, some don't. My client wishes to display the posts in alphabetical order, ...
0
votes
0answers
42 views
Front-end login system
After some googling for about 2 days, I am here with a simple wordpress front-end login system.
Please let me know if there is anything wrong with it, or if there is anything I can do, for improving ...
4
votes
1answer
86 views
Add user profile fields
I have this PHP function that adds custom user profile fields to WordPress. It saves the field through the WooCommerce form-edit-my-account.php file. I have a lot of repeated code, and would like to ...
3
votes
1answer
20 views
Bash Compress Managed Directory Ignoring .git, bower_components, node_modules, etc
Fairly easy way to compress a wordpress plugin (or similar) as a zip file without including all the dependencies used to create and manage the development, but which don't belong in the final product.
...
3
votes
2answers
108 views
Inserting a name into a database table
I want to ask you if my PHP code is safe enough. I don't know if I should escape special characters in string after regex validation:
...
3
votes
1answer
34 views
User generated filter and content
I am writing a (multi) filter that is created when the user enters in the data through wordpress. There can be anywhere between 2 - 10 filters so I need this to be as dynamic as possible. My first ...
0
votes
0answers
33 views
Adding two tinyMCE buttons to the WordPress editor
I'm pretty new to JavaScript, and I built a plugin that adds two tinyMCE buttons to the WordPress editor. The buttons wrap a selected text with shortcodes. One of the two buttons is a menubutton, and ...
3
votes
1answer
79 views
WordPress anti-spam script
This is the first PHP script I have written. It downloads and installs a plugin called "anti-spam" by using the WordPress API. It also provides an option to either delete all comments or delete the ...
2
votes
1answer
52 views
Listing links for categories
I've developed some PHP that grabs all of a business listing's categories and then displays just the children categories. This is built on Wordpress. I'm still in the learning process and would ...
5
votes
1answer
130 views
Related links for WordPress posts
I have written the following class which is part of a pagination system in Wordpress. The class works as expected and also works as expected when used in the system.
Just as background, the class ...
2
votes
0answers
19 views
Limiting WP user's access to the amount of credits they have
I like this solution but maybe there is another way. My goal with this is to limit user editing to the amount of credits they have. What do you think?
Here is what it does:
Credits are stored as ...
2
votes
2answers
118 views
PHP function (in WordPress) echoing HTML
I'm really new to PHP, and a little less so in WordPress. I've created a working function that spits out some static HTML into a page template in WordPress. I'd like to know if there is a best ...
1
vote
0answers
35 views
Time table for users
I'm working on a WordPress theme and creating a time table which will be easy to complete by users.
In the back-office, there are a checkbox for each days:
...
1
vote
1answer
30 views
Multiple Wordpress metaboxes in fewer different functions
Is it possible to call multiple metaboxes in Wordpress with less duplicate functions? For instance, these are my current metaboxes (3 of them, one is a checkbox and two others are text input fields):
...
1
vote
1answer
77 views
Interface injection and common functionality between classes
I'm trying to get my head around the OOP principles and coding my own classes. As a means to learn, I have decided to convert a couple of functions I have written in Wordpress to OOP classes. These ...
2
votes
1answer
70 views
Reading and Converting XML File to Array
I'm using WordPress ( PHP Based Platform ) and I'm trying to read an external XML File, convert it into a usable array, then compare two arrays - one from the xml file and another from an options ...
6
votes
2answers
298 views
Checking for existence of URL parameters
I'm busy rewriting some from my spaghetti code into OOP classes. I'm still learning OOP and very new to the concept. From help from this answer from @EliasVanOotegemto on a previous question I've ...
2
votes
1answer
142 views
Sort by a custom date field
I've got this code to work, but being really new to PHP, I don't know if this is proper. I've sorted a CPT loop by a custom date.
I'm displaying items from most recent (or future date) to oldest
if ...
3
votes
2answers
186 views
Correctly coding an OOP object
I have a couple of functions in WordPress that I'm rewriting to OOP. All these functions are interlinked in some way and also reuse code from other functions.
This is an example of the first class ...
0
votes
0answers
32 views
apply_filters for validation function
I am using the function below to validate my color options, but I am not 100% sure if I am doing it right, particularly this bit of code:
...
0
votes
0answers
362 views
jQuery Scroll to ID on Next Page Loading and Back to Top Anchor
I'm no jQuery fundi and I kinda hacked this together, it does work. I just want to know if there's a better smoother more code compliant way of doing it?
...
1
vote
1answer
190 views
Button to follow / unfollow a user
As a beginner in coding, I have just written this code.
The code should Add a form with a button to each user profile, it named Follow or Unfollow. It updates the user meta named "following" for the ...
2
votes
2answers
65 views
WordPress: multiple loops
I have two loops on my page - each with their own category. It works, but I don't know if this is the best practice as I'm pretty new to this stuff.
...
2
votes
1answer
89 views
Navigating calendar by week
I started actually learning a little programming last year, as opposed to just hacking away at libraries and found fragments.
For a WordPress plugin I needed to navigate through weeks, which I ...
2
votes
1answer
244 views
Removing stray brackets from in between shortcodes
I was wondering if someone could point me in the right direction for cleaning up this code.
WordPress uses shortcodes in the form [shortcode] to add extended functionality to posts and pages.
What ...
5
votes
2answers
71 views
First WordPress template
I wrote my first template, but didn't include any styling. What do you think? What's good what's bad?
...
2
votes
1answer
31 views
Sorting of nested categories inside a Common Table Expression
I have a PostgreSQL database which contains (among other things) the following table definition:
...
1
vote
1answer
124 views
Automatic password security test for WordPress
I was bored the other day and wrote the following little script to attempt to find insecure passwords for WordPress blog owners so they could be notified of how easy it would be to crack their WP ...
5
votes
3answers
5k views
Foreach within Foreach loop - is this code poor form?
I am using the following code poor form. I am interested in how I can optimise this and use the correct methods. I understand the DRY concept and will look to employ that throughout my code. However, ...
1
vote
0answers
61 views
Displaying site posts in a layout based on image
This basically shows the posts of the site in a layout like, 1 row image + text, and the next row text + image, but when there is no image, it only displays text in the entire row.
I want to know a ...
1
vote
0answers
85 views
Foreach with the aim of removing the need for a $global
Below is a function (part of a procedurally written Wordpress plugin) which iterates through a multi dimensional array of regions, adding them to a custom hierarchical taxonomy. In the spirit of ...
6
votes
3answers
663 views
Check efficiency of PHP code that will query over 8500 orders
I am querying all orders from a WordPress database that uses the WooCommerce Bookings plugin. I want to display upcoming bookings, and there is a potential to have every hour within 2015 to be booked; ...
2
votes
1answer
67 views
DB security and efficiency in WordPress plugins
I recently wrote my first WordPress plugin, which was also my first PHP project. After I was done, I didn't care for the code at all, so I have spent the past couple of days refactoring it. I'm trying ...
2
votes
0answers
171 views
Plugin that grabs the coordinates of all the cities in our database
I have a plugin that grabs the coordinates of all the cities in our database working in WordPress here.
...
3
votes
1answer
171 views
Social Share count
I am creating a social sharing counter plugin for my WordPress blog. I want to fetch the counts of number of likes, shares, Facebook comments (I am using Facebook comment box), twitter tweet counts ...
10
votes
2answers
274 views
First attempt - Wordpress PHP Settings API wrapper
I've been working on what is essentially my first proper attempt at making a useful PHP wrapper class for the Wordpress Settings API. It works great so far and I plan to add more methods as I go so ...
6
votes
2answers
627 views
Trim string of words based on character count
I needed a simple way to trim a string of words based on a max character count. I also needed to cut in-between words. Using WordPress, here is what I came up with, but I feel like it could be more ...
2
votes
0answers
182 views
Automatic submenu
The goal here is to create a Top Level Menu that automatically pulls child pages without the need to manually add them to said menu. I didn't know any other way to accomplish this without a walker, of ...
2
votes
2answers
124 views
How do I refactor this responsive background images code?
In my latest project I am using fullscreen background images for each page. I decided to write some code to fetch the different thumbnail sizes and then use it as a background for the appropriate ...
2
votes
1answer
98 views
Wordpress filter post by metavalue
I am making a filter to get posts by status that are saved by post metavalue in a Wordpress plugin. It is a question and answer system, where the question and answer are post objects.
...
6
votes
3answers
311 views
Evaluate a Contact Form CSS
I am a total novice to web development, but I am trying to be a WordPress developer and have been actively at it for some weeks now. All self-taught with the world's best tool as my aid: the internet. ...
5
votes
1answer
136 views
Is this a good WP Post Type template script?
I have created this class for my WP theme. It allows you to create templates for a meta box which relates directly to a custom frontend template to have better control of the content displayed on the ...
3
votes
1answer
378 views
WordPress Functions.php file
I am making a WordPress "framework" for myself. Looking at the functions.php file file, is there redundant or bad code that could be changed or some code that could be good to add?
The functions.php ...
3
votes
1answer
430 views
Plugin for WordPress and Foundation Reveal
I figure that someone here probably knows a much better way to do this. I'm still figuring out AJAX and jQuery, so I consider that I still need to master quite a bit of knowledge.
My function ...
3
votes
1answer
170 views
Exporting data in a WordPress widget
I have some custom tables in a Wordpress database that I need to export to CSV. I created a dashboard widget to help with this based on some assistance given to me on on one of my SO questions. It ...
2
votes
3answers
149 views
Displaying fields in a sidebar of a custom page template
I'm beginning with PHP programming and would appreciate a critique on my code and how I could make it more efficient, rather than repeating the if statements.
What ...
2
votes
1answer
336 views
Simple theme options held in array
I have created WordPress theme options using an array, and it is working. There are 5 type of input: text, textarea, ...
6
votes
3answers
231 views
First Wordpress plugin for saving a post
This is my first Wordpress plugin. I would love some input from the WP/PHP/JavaScript gurus out there. It's a simple plugin that saves a post using ctrl-Q and opens a preview in a new or current ...
1
vote
1answer
93 views
Wordpress $wpdb->row Query Check
Looking at $wpdb class, I found get_row, and I am unsure if the function automatically prepares the query. I believe it does not ...