When I try to use Autoload in my Wordpress plugin I get an unexpected error: not finding Warning: require(/home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/../phpunit/phpunit/src/Framework/Assert/Functions.php): failed to open stream: No such file or directory in /home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/autoload_real.php on line 55 Fatal error: require(): Failed opening required '/home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/../phpunit/phpunit/src/Framework/Assert/Functions.php' (include_path='.:/usr/share/php') in /home/251650.cloudwaysapps.com/geytjjwugd/public_html/wp-content/plugins/gik25-microdata/vendor/composer/autoload_real.php on line 55 I've uploaded the files via SFTP Called require_once("vendor/autoload.php"); in the plugin entry file (it works) *The autoload.php file contains require_once DIR . '/composer/autoload_real.php';
I am trying to add google fonts to a custom WordPress theme. Therefore I tried to enqueue selected three font faces at once to make it fast loading. So, I use the below codes to register and enqueue the same. wp_register_style('googlFonts', '//fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&family=DM+Serif+Display&family=La+Belle+Aurore&display=swap'); wp_enqueue_style('googlFonts'); When I search via source code I can only see the last font. Other fonts are not loading. Even I can't see the same complete URL in the source code. Below is what I saw from the …
Is there no mechanism which purges old options from the DB? I tried a few plugins in the past and I found out that there are a few pretty long option strings which are set to autoload but IMHO not used at all - as I'm not using those plugins anymore. So I guess it makes sense to remove those options completely - but I'm not 100% sure whether I miss some implications? Am I mistaken, or this the unfortunate …
I'm currently trying to optimize my WP-page. I checked with "Query Monitor" and I see a lot of options which are fetched on every pageload (not a huge runtime cumulated, but still ~15-20 get_options SQL calls logged by Query Monitor) - would it make sense to just set those specific identified options to "autoload" if I see them in every pageload - and is it safe to do, or will maybe the corresponding plugin override this to "autoload=no" again in …
I am cloning a friends WP installation using mysqldump, rsync and docker to fetch all files and data. When running the site, I get the following error: Fatal error: Uncaught Error: Class 'Jetpack_Options' not found in /var/www/html/wp-content/plugins/jetpack/class.jetpack.php:2154 Stack trace: #0 /var/www/html/wp-content/plugins/jetpack/class.jetpack.php(702): Jetpack::get_option('edit_links_caly...') #1 /var/www/html/wp-content/plugins/jetpack/class.jetpack.php(403): Jetpack-&gt;__construct() #2 /var/www/html/wp-content/plugins/jetpack/load-jetpack.php(89): Jetpack::init() #3 /var/www/html/wp-content/plugins/jetpack/jetpack.php(149): require_once('/var/www/html/w...') #4 /var/www/html/wp-settings.php(371): include_once('/var/www/html/w...') #5 /var/www/html/wp-config.php(90): require_once('/var/www/html/w...') #6 /var/www/html/wp-load.php(37): require_once('/var/www/html/w...') #7 /var/www/html/wp-blog-header.php(13): require_once('/var/www/html/w...') #8 /var/www/html/index.php(17): require('/var/www/html/w...') #9 {main} thrown in <b>/var/www/html/wp-content/plugins/jetpack/class.jetpack.php</b> on line 154 The class exists, it is not …
Coen Jacobs' Mozart is a tool to prevent namespace conflicts in Wordpress themes/plugins which utilize Composer for dependency management. It's similar to PHP Scoper but is described as simpler and Wordpress-oriented. I have mozart configured as follows: "extra": { "mozart": { "dep_namespace": "MZoo\\MyPlugin\\Dependencies\\", "dep_directory": "/src/Dependencies/", "classmap_directory": "/src/Classes/", "classmap_prefix": "MYPREFIX_", "packages": [ "htmlburger/carbon-fields" ], "delete_vendor_directories": true } }, All of the Carbon Fields files are namespace-prefixed and migrated to src/Dependencies/Carbon_Fields except the vendor/htmlburger/carbon-fields/config.php file, which resides above the core directory with …
I'm new here and I'm also new to WordPress. I'm currently trying to connect my WP site to SharePoint and I'm stuck. My approach to solve this was to search for php libraries that would help me with this connection. I found this two: PHP-SharePoint-Lists-API phpSPO The last one seems better but I'm having a problem to use classes in php files after installing dependencies with Composer in the theme I created. require_once __DIR__ . '/vendor/autoload.php'; use Office365\Runtime\Auth\ClientCredential; use Office365\SharePoint\ClientContext; …
I wrote a WP theme using namespaces and autoload. Everything went smooth until I started to use WP classes which I understand of course because I understand how namespacing works. My question is, is there a way possible to use a Wordpress class inside one of my theme classes, for example I want to use $wp_customize, an instance of WP_Customize_Manager? How would I achieve that, keeping my OOP theme structure. UPDATE: Thanks to Pat J. I was able to solve …
In a custom WordPress plugin I have a folder /classes with about 20 classes. Classes sometimes change, come and go. I want all those classes from the folder to be loaded automatically. No my idea was to load those files by a simple loop require: foreach (scandir(dirname(__FILE__)."/classes/") as $filename) { $path = dirname(__FILE__) . '/' . $filename; if (is_file($path)) { require $path; } } However this does not work because there are subclasses loaded before superclasses and I get a …
I'm using PSR-4 autoloading and namespacing for a new plugin. However, because my plugin is namespaced (and all it's classes are), I can't seem to extend a BuddyPress class (BP_Attachment) successfully as it doesn't want to pass the if ( class_exists( 'BP_Attachment', false ) ) check. I've tried to require it, "use" it, and more. Nothing works. Since BuddyPress doesn't use namespacing am I out of luck?
I'm writing a simple plugin with oop and using namespaces and autoloading. Here is my main file: add_action('plugins_loaded', array(My_Test_Plugin::get_instance(), 'plugin_setup')); class My_Test_Plugin { /** * Plugin instance. * * @see get_instance() * @type object */ protected static $instance = NULL; /** * URL to this plugin's directory. * * @type string */ public $plugin_url = ''; /** * Path to this plugin's directory. * * @type string */ public $plugin_path = ''; /** * Access this plugin’s working instance * …
I am trying to work with autoloader in my plugin. In the main file of my plugin I have use My_Plugin\Includes; require_once( plugin_dir_path( __FILE__ ) . 'includes/class-autoloader.php' ); $autoloader = new Includes\Autoloader(); And in my includes/class-autoloader.php file I have namespace My_Plugin\Includes; class Autoloader() { public __construct() { spl_autoload_register( [ $this, 'autoloader' ] ); } public autoloader( $class_name ) { error_log( print_r( $class_name, true ) ); if ( strpos( $class_name, 'My_Plugin' ) === false ) { return; } } } But …
I've recently made my website and added facebook web plugin script and instagram script on the widget bar. But when I go from the Homepage to another Page it's not loading. It's just loading when I refresh the site I currently am. Someone knows how to solve this?
First of all thank You for Your time. I use autoload in my 2 plugins. They have to different namespaces but i want to build one main plugin with autoload for this two plugins. In future i am going to add more plugins. How should i organize that? in plugins i have to namespaces namespace plugin_namespace\controller\some_cntr and namespace sec_plugin_namespace\controller\some_cntr everything is object oriented and here is my autoloader witch exists in both plugins (i will have only one if it …
I'm trying to autoload the vendor/autoload.php from my parent theme into my child theme. heres what i have tried but to no avail: function beast_theme_setup() { $var1 = get_theme_root_uri() . '/beast/vendor/autoload.php'; $var2 = get_theme_root_uri() . '/beast/functions.php'; $var = locate_template( array( $var1, $var2), true, false ); var_dump($var); } add_action( 'after_setup_theme', 'beast_theme_setup', 11 ); and include get_theme_root_uri() . '/beast/vendor/autoload.php'; Any help on this would be amazing. Thanks Jake.