Jonathan Bossenger
Forum Replies Created
-
Forum: Localhost Installs
In reply to: PHP missing the MySQL extensionHi @rthwm can I check how you installed Apache, PHP, and MySQL on Windows? Did you install each piece separately, or are you using something like WampServer?
Secondly, when you uncommented the mysqli extension in php.ini, did you restart Apache?
Last but not least, can you create a php file with the following code, and browse to it.
<?php phpinfo();And then check if it has a mysqli section (something like this screenshot https://tinyurl.com/24886cwk)
Forum: Developing with WordPress
In reply to: connecting more variables@sacconi can I just confirm what I understand you want to do here.
- You are storing a meta value on the author with the key
pulizia_esc - You also want to store a meta value on the post with the key
function_pulizia - Based on your description, they are all Euro values (eg amount in Euro)
- You want to be able to output the total of
pulizia_escon the author andfunction_puliziaon the post and echo this in the div with classpulizia_esc
In that case, something like this should work:
$pulizia_esc = intval( get_the_author_meta( 'pulizia_esc', $post->post_author ) ) + intval( get_post_meta( $post->ID, "function_pulizia", true ) ); if ( $pulizia_esc !== 0 ) { $pulizia_esc = '<div class="pulizia_esc">' . $pulizia_esc . '</div>'; }What this code does is convert the two meta values to integers using PHP intval function, and then add the two integers together using the
+, to get the total.Then the conditional checks if the value is not zero, and if it isn’t, performs the string concatenation using the . with the integer value. When you concatenate an integer to a string, PHP will convert the integer back to a string.
What I would suggest as a small improvement is to also set $
pulizia_escto an empty string if the total is zero, so that you don’t get0output to the screen$pulizia_esc = intval( get_the_author_meta( 'pulizia_esc', $post->post_author ) ) + intval( get_post_meta( $post->ID, "function_pulizia", true ) ); if ( $pulizia_esc !== 0 ) { $pulizia_esc = '<div class="pulizia_esc">' . $pulizia_esc . '</div>'; } else { $pulizia_esc = ''; }I would also point out that if you plan to include decimals (i.e. cents) to the values, you might want to use floatval and not intval.
Last note, to make the above code cleaner and less prone to error, I would define a custom function to perform the calculation and return the string.
function generate_pulizia( $post ) { $pulizia_total = intval( get_the_author_meta( 'pulizia_esc', $post->post_author ) ) + intval( get_post_meta( $post->ID, "function_pulizia", true ) ); if ( $pulizia_total === 0 ) { // If the total is 0 return an empty string. return ''; } // Otherwise return the total. return '<div class="pulizia_esc">' . $pulizia_total . '</div>'; }And then call that function wherever you need to generate the output
$pulizia_esc = generate_pulizia( $post );Forum: Fixing WordPress
In reply to: How to unlock media pages (attachments)?Hi @sdax
In order to “unlock” this functionality, you’re probably going to have to hook into one or more of the ‘pre_get_’ hooks in a theme or child theme’s functions.php file, or a custom plugin, to allow different data types.
For example, for a search, I found this code which uses the
pre_get_postshook to include attachments in search results.add_filter( 'pre_get_posts', 'pre_get_attachment_search' ); function pre_get_attachment_search( $query ) { if ( $query->is_search ) { $query->set( 'post_type', array( 'post', 'attachment' ) ); $query->set( 'post_status', array( 'publish', 'inherit' ) ); } return $query; }For the comments, you would probably need to use the
pre_get_commentshook, but without diving into the code I’m not sure what you’d need to set on the$queryto include attachment comments.Forum: Developing with WordPress
In reply to: website healthHi @eliot1988
Is this indication under the critical issues list, or the recommended improvements list?
If it’s under recommended improvements, it’s probably ok to ignore it, unless the scheduled event is something that you need to work.
It would also help if you’re able to share a bit more detail about the notification message, as that will help with determining how important it is.
Forum: Networking WordPress
In reply to: WordPress multiste, inside wordpressHello @aivts
Can I confirm what you mean when you say
when I include the multisite lines in the wp-config.php. Are you referring to the following line to Allow Multisite:define( 'WP_ALLOW_MULTISITE', true );Or do you mean the lines that your WordPress install presents during the Enabling the Network step?
define( 'MULTISITE', true ); define( 'SUBDOMAIN_INSTALL', false ); define( 'DOMAIN_CURRENT_SITE', 'abc.com' ); define( 'PATH_CURRENT_SITE', '/web/' ); define( 'SITE_ID_CURRENT_SITE', 1 ); define( 'BLOG_ID_CURRENT_SITE', 1 );If you mean this step, did WordPress also ask you to add some lines to your .htaccess file?
RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase /web/ RewriteRule ^index\.php$ - [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] RewriteRule . index.php [L]If you are running the server on nginx, the .htaccess file solution might not work (it depends on how the server is configured) and you might need to add those lines to your nginx config manually. Additionally, the nginx config lines are slightly different from the Apache .htaccess ones.
I was able to replicate your environment on my local Apache setup, and enable the multisite on the WordPress install in the /web/ directory, so I’m thinking it might be the nginx configs that are needed.
Forum: Installing WordPress
In reply to: Mysql Doesnot create on staging siteHello @yeknafar
The error you are getting looks like you need to update the user trying to create the MySQL tables, as that user doesn’t have the required permissions to create tables on the database environment you’re trying to set it up on.
Are you trying to create a copy of your site on your web hosts staging environment, or on a local WordPress installation? If it’s with your web host, best to check with their support.
If locally, how are you creating the staging copy of the site and what local WordPress installation software are you using?
Forum: Everything else WordPress
In reply to: Existing images show errorI’m not aware of any problems, it could be the upgrade, or it could also be a plugin or theme conflict. That’s why I asked if you’re able to perform a downgrade first, to see if things resolve themselves.
With regards to debugging information, if you’re able to open your browser’s developer tools and go to edit a post or page where the problem is happening, you should see any errors being reported in the Dev Tools Console (example for Chrome browsers).
Forum: Everything else WordPress
In reply to: CPT delete from WordPress or MySqlHi @tazcrzy
In my opinion, it’s usually best to “trash” from inside WordPress, as it should also delete any associated data (eg metadata). Additionally, if any custom plugins need to delete associated data, their delete routines would also kick in if you trash from within WordPress.
You could consider automating this process, by gathering the custom post ids, looping through the ids, and calling wp_trash_post() on each one. This would be faster than doing in the admin UI.
However, it is possibly faster if you delete via MySQL, you will just need to ensure that you also delete any associated data.Forum: Fixing WordPress
In reply to: impossible to center logo – due to custom css?Okay, I was able to replicate your setup by disabling the “Display Site Title & Tagline” setting under Site Identity in the Customiser. It seems disabling that setting moves the site logo container into the site branding container.
If I re-enable that setting and then add the following custom CSS to the Additional CSS area of the Customizer (not using the SiteOrigin CSS plugin), I get the result you are looking for:
.site-header > .site-logo { border-bottom: 0; } .site-branding { display:none; } .primary-navigation { margin: 0 auto; }Screenshot: https://tinyurl.com/28pyuzqe
Forum: Fixing WordPress
In reply to: impossible to center logo – due to custom css?Were the only changes you made by using the SiteOrigin CSS plugin? Looking at the HTML source code, there are also differences in the HTML structure. Did you make those using the same plugin, or somewhere else?
Forum: Fixing WordPress
In reply to: impossible to center logo – due to custom css?Thanks.
I’ve installed and activated the plugin, and applied the CSS you’ve sent me, but the logo is still centered above the site title and menu as per my original screenshot. Have you made any other changes to the layout?
Forum: Developing with WordPress
In reply to: Rest API response headers now lowercaseHi @lyurk I did a bit of digging into this, and this was the feedback I received.
Headers are case-insensitive in all versions of HTTP.
HTTP clients also need to handle this per the spec; for example, Requests (which WP_Http uses) has a case-insensitive dictionary for this
So it’s generally expected that headers will be case insensitive, and to not expect them to be sent using a specific case, even if they are set that way in the code.
Forum: Fixing WordPress
In reply to: impossible to center logo – due to custom css?Thanks Henry
There seem to be a couple of Custom CSS plugins available, are you able to give me a bit more detail about the specific one you installed?
I’d like to try and replicate your configuration as much as possible.
Forum: Fixing WordPress
In reply to: Content shifts off pageHi @jamescready
It looks like it could be possible that something in the Sydney theme is conflicting with the default column styles to cause this.
Are you able to test this out by switching to one of the default themes (like Twenty Twenty-Three) and see if the problem still exists?
If your web host supports staging sites, I would recommend making a copy of the live site to a staging site and testing it out there.
Forum: Everything else WordPress
In reply to: Form won’t displayHi @cutenmore
The link you have shared in your support thread is a location in your WP admin dashboard, which I’m not able to access.
Do you perhaps need to publish the page, for it to display on the front end?
- You are storing a meta value on the author with the key