Questions tagged [wordpress]

WordPress is a free and open source blogging tool and a content-management system (CMS) based on PHP and MySQL.

Filter by
Sorted by
Tagged with
1
vote
0answers
27 views

WordPress plugin to reveal coupons after several visits to a page

My file tree is here. It does not look good. I would appreciate any tips you have on improving code organization. My React mindset of breaking folders by component didn't carry over well into php/...
1
vote
1answer
21 views

Prefixing prices of certain product categories with text in Woocommerce

I had the need to prefix the price for certain product categories on only the shop page (because the price can be higher depending on extras that the customer might want). These were my requirements ...
3
votes
1answer
39 views

Filtering wordpress comments by votes

Hello and sorry for my bad grammer! I have website that based on user comments and I'm trying to filter comments by "most liked first, most disliked first" etc... I have a custom table for comments ...
0
votes
0answers
26 views

WordPress hook to add URL-rewriting rules for articles with language variants

Please look at this working WordPress code: ...
1
vote
0answers
14 views

Custom WordPress SQL query to get posts and users using term_id

I have a WordPress site with multiple custom post types, that all share a common custom taxonomy. Users can also be tagged with terms from this taxonomy. After giving up on ...
1
vote
0answers
39 views

Proper image sizes in WordPress

I wanted to create a set of functions that would allow me to easily implement images for multiple screen resolutions in my custom page templates. WordPress offers some functionality for implementing ...
1
vote
0answers
23 views

Simple cart update WordPress plugin

I created a plugin to update cart automatically on quantity change with some additional options. I want to focus only on the main plugin file, skipping uninstall.php and .js file which are entirely ...
2
votes
0answers
24 views

WordPress rest api basic auth with IP check

I'd like to use basic auth with the WordPress API, but restrict the capability to a single IP address. I've updated the existing code from here: https://github.com/WP-API/Basic-Auth accordingly. It ...
1
vote
2answers
63 views

PHP subscription workflow

I've creating a working subscription workflow for my webpage, which heavily utilizes a set of functions I've created for this purpose. However, after doing some testing (functionality works fine), I'...
0
votes
0answers
27 views

A smarter way to build custom wordpress permastructures and keep them updated in admin?

I've done this many times.. Breafly speaking, I've got a custom post type with custom taxonomy (say products_categories), and want model single urls like this structure: ...
1
vote
1answer
65 views

Feeding PHP variables to a number of HTML elements

The following code works fine, however, I'm trying to simplify it. I wrote it but I'm a beginner PHP coder. I can see that most probably the use of a function or class would be better... or anything ...
1
vote
0answers
39 views

Load more and filtering - WordPress AJAX

In my WordPress theme I have built a function that uses Isotope Layout by Metafizzy to accomplish filtering and sorting. I have used a mix of AJAX and JQuery to accomplish this, however I feel the ...
2
votes
0answers
39 views

Generating two Woocommerce Order CSV files based off url query

I wrote this code about one year ago. I'm looking to refactor it to be solid SOLID and secure, as this is being generated off a custom endpoint. The script is to read parameters from a query and ...
2
votes
1answer
52 views

Checking if a shipping method exists

I am trying to create a custom WordPress/WooCommerce function in PHP. I am a newbie and would really appreciate some feedback on my code and how to improve the code! Right now it feels like there is a ...
2
votes
0answers
21 views

Create a new WordPress admin page, and add an admin table to it

I completed this WordPress coding task as part of an interview. I'm hoping someone can review my work and comment on everything, especially my general approach to the task, and the sanitization of ...
3
votes
3answers
106 views

Check if a postcode is in a list

I'm looking for improvement / advice / reviews on how I can improve this code. I feel like there is a better way or more efficient way of doing this and I am over looking it. The Plugin I made is ...
2
votes
0answers
26 views

WordPress plugin for shipping calculation

I am writing a WordPress plugin that allows shipping calculation on the product page. Originally, shipping calculation is only available in the cart. To calculate shipping costs on product page, ...
1
vote
0answers
20 views

WordPress plugin development - plugin-name.php file and plugin files/folders structure

I am creating my first WP/WooCommerce plugin. I was following instructions from WordPress Codex during development, but I wanted to review it here, to make sure I am on the right path. First things I ...
1
vote
0answers
27 views

WordPress plugin for listing users

I was given an opportunity to join a WordPress contractor/freelancer website and was asked to build a plugin that would list the wordpress users in the database, allow you to filter them based on ...
0
votes
1answer
55 views

Formatting fractions found in a given string to html fraction

I'm working on a site running woocommerce and wp where the user will add/has added a dimension attribute. The dimension string will take the following format originally: Ht: 30 1⁄2" W: 22 1⁄2" D: ...
3
votes
1answer
301 views

JavaScript responsive menu (dropdown/dropup)

I have the following front-end code for a responsive navigation menu which I thought using in my WordPress website. Clicking the .burger element should cause ...
3
votes
1answer
64 views

Conditionally displaying a notice about free shipping in Woocommerce

I wrote PHP code to display a Woocommerce notice - "free shipping for $40 & under" only once on shop page and once on cart page, but also in cart should not be more than 40$. The code works, but ...
1
vote
2answers
40 views

chmod all .htaccess files under all website dirs under public_html dir

This is my code to chmod all .htaccess files under all website dirs under public_html dir. The reason I use this code is to make sure WordPress plugins won't "...
0
votes
0answers
14 views

Hiding and repositioning some elements for some WordPress posts

I have to gather a few posts (a Wordpress site) and I need to hide some elements and move some others. There are 2 simple ways to do this, which one of these is better if there is a better one and why?...
2
votes
0answers
35 views

Creating an object handler that loads objects in an array in PHP

I am creating tooltips that I will use throughout my site. Each individual tooltip is created as an object, all of these tooltips need to be ingested with these rules: I should be able to hold an ...
1
vote
1answer
40 views

Nginx-WordPress conf

This is how I create am Nginx virtual host for a WordPress webapp. I did best to keep it as minimal as I can while having a working webapp. Please review it: ...
2
votes
2answers
94 views

Nginx-WordPress installer for Debian

I have written the following Bash script which includes an Nginx WordPress bootstrapper: A program establish WordPress apps fast on a Debian-Nginx environment. It utilizes CertBot for HTTPS, SSHguard ...
1
vote
1answer
35 views

Four-lines script to make an immediate DB and document root zip backup

What do you think of my script to make an immediate DB and document root zip backup? Any flaw you might find. Please inform me of it: ...
3
votes
1answer
78 views

Create a WordPress site data with Nginx app data automatically

The following script is aimed for Ubuntu >=16.04 LEMP environments with PHP-FPM >=7.0, MySQL, WP-CLI, Certbot, and ...
2
votes
1answer
104 views

Webapp Substrate script for WordPress on Debian-Nginx

The following script creates a webapp substrate for WordPress webapps/websites on Ubunu-Nginx with PHP-FPM and Mysql environments, with Certbot, while all software is uncustomized. Such substrate ...
2
votes
1answer
94 views

Nix cron daily and weekly scripts for a minimal Nginx server environment

I've created the following Nix cron for daily and weekly scripts for a minimal Nginx server environment (as part of my larger script). The daily cronjob updates WordPress and brings back original ...
1
vote
0answers
33 views

WordPress plugin that accepts a zip file, moves it to a specific folder, then unzips it

I wrote a plugin that allows a user to upload a zip file, then the plugin will create a unique directory inside of 'uploads' and then it will unzip the file. I did this so if a user needs to upload ...
3
votes
1answer
74 views

Importing and deleting product data in WordPress

I am interested in how to handle errors/exceptions/returned data correctly. For example, I have a script which creates, updates and deletes products data. Here is method that receives data from an ...
3
votes
0answers
32 views

Bash webapp duplicator

I've written the following Bash script used to duplicate a webapp/website you have (say, a Wordpress website) locally on your server environment, for testing purposes, indicating after 2 days if you ...
1
vote
1answer
4k views

Get file absolute path from file URL in PHP

Reading several questions regarding the topic, I made my function to return file's absolute path from the file URL. As I'm using this in an WordPress environment, hence I availed ...
2
votes
1answer
148 views

Plugin for showing cross-sells on the single product page in WooCommerce

I made a custom plugin for showing cross-sells on the single product page in WooCommerce, however i need to know if this is secure and possibly act as an attack vector. Additionally, is there a better ...
4
votes
0answers
64 views

WordPress contact form plugin PHP and WP_REST improvements

TL;DR This month I wanted to improve my WordPress knowledge and create a simple form that wasn't bloated with features but was secure. I wanted to make sure this plugin improved my knowledge of: ...
3
votes
1answer
1k views

Displaying a price quote depending on the selected number of rooms

I've written a WordPress plugin that displays a price quote based on what options are chosen in the settings and then what the user chooses with HTML <select> ...
1
vote
0answers
11 views

WordPress MU generate navigation from all sites with current site highlighted

I'm wondering if this is the most efficient way to generate a navigation in WordPress MU that contains links to all sites, with the current site highlighted. Also looking for any advice on PHP style ...
2
votes
1answer
140 views

PHP function which filters content from Wordpress database (wp_posts table)

I worked on a hybrid mobile application for a newspaper company. They had a Wordpress website with news content (in a wp_posts table) which they wanted to be displayed in the application. I built the ...
1
vote
1answer
39 views

Elegant wp-query markup for repetitive post-type category loops

For WordPress sites, I always end up building custom post types. They usually have categories, but I don't use much of the 'archive' abilities. This site, for example, is for a film director and so it ...
0
votes
1answer
46 views

Displaying API results inside a WordPress page template

I've created a WordPress page template that calls an API using Httpful and formats the results. This is my first time using APIs on a page, so I'd like to know if this is the right direction to go in. ...
1
vote
1answer
84 views

Outputting a logo from the Wordpress Customiser

I managed to solve a little problem I had myself by reading and modifying. My code works, but as a novice I would like to ask if you could advise me of a cleaner way to achieve the same thing. ...
1
vote
3answers
105 views

Ensure that all `h2` tags have a `span` inserted

I'm running these on page load to ensure that all h2 tags have a span inserted (it's a large WordPress site that needs to have ...
2
votes
1answer
62 views

Show and paginate only child categories with wordpress query

I'm using this piece of code to show and paginate only child categories but this is horribly slow (49 queries in 9,799 seconds.). Where did I make mistakes and how ...
3
votes
0answers
47 views

Custom WordPress Menu

I have recently delved into the world of OOP programming with PHP. I wanted to add my own custom menu to the Wordpress Admin area, and came across a tutorial, which I have followed, and the code is ...
2
votes
0answers
31 views

Text Snipper WordPress Plugin in JavaScript

I am making a text snipper plugin for WordPress. Basically, I want it to truncate multiline text that overflows the height of its container and add "...". My code works for direct child elements, too. ...
2
votes
2answers
515 views

PHP create JSON file from Twitter API

I've been reading more on PHP JSON and APIs I wanted to play around and pull a user's tweets so I wrote a function that requires the TwitterAPIExchange wrapper. The code: ...
2
votes
1answer
107 views

WordPress Settings Plugin security

I'm wanting to step into plugin development so I can eventually push to WordPress.org so I wanted to go through and really learn how to properly develop a Plugin's settings page. I went through ...
1
vote
1answer
52 views

A PHP function that prints the url based on path

I'm trying to come up with a smart wordpress inspired PHP function that builds an url for my CMS. It has some different requirements that are almost all fulfilled so far. Must use correct domain Must ...