php - Advanced Custom Fields: dirname( __FILE__) returning wrong URL on shared server for CSS and JS includes -



php - Advanced Custom Fields: dirname( __FILE__) returning wrong URL on shared server for CSS and JS includes -

i'm adding advanced custom fields pro (v5) simple plugin i'm creating.

i'm using tutorial on acf website: distributing acf in plugin/theme. tutorial calls using get_stylesheet_directory(), theme. replaced dirname(__file__).

in step 3, include_once works fine dirname(__file__). steps 1 , 2 work including files, run issue when javascript , css files included acf. returns urls following:

http://example.com/templates/wp-starter/nfs/c05/h03/mnt/70376/domains/example.com/html/templates/wp-starter/wp-content/plugins/simple/acf/css/global.css?ver=5.0.0

this get:

http://example.com/templates/wp-starter/wp-content/plugins/simple/acf/css/global.css?ver=5.0.0.

i using media temple's grid server (shared hosting).

here relevant code plugins/simple/simple.php:

// 1. customize acf path add_filter('acf/settings/path', 'my_acf_settings_path'); function my_acf_settings_path( $path ) { // update path $path = dirname( __file__ ) . '/acf/'; // homecoming homecoming $path; } // 2. customize acf dir add_filter('acf/settings/dir', 'my_acf_settings_dir'); function my_acf_settings_dir( $dir ) { // update path $dir = dirname( __file__ ) . '/acf/'; // homecoming homecoming $dir; } // 3. include acf include_once( dirname( __file__ ) . '/acf/acf.php' );

how can right url scripts , stylesheets?

i tried using next in config.php, didn't work either:

define('wp_content_dir', 'http://example.com/templates/wp-starter/wp-content'); define('wp_plugin_dir', 'http://example.com/templates/wp-starter/wp-content/plugins');

i enqueue these scripts , stylesheets separately, nice if didn't have that.

i resolved issue using $dir = plugins_url() . '/simple/acf/'; in step 2. kept else same.

// 2. customize acf dir add_filter('acf/settings/dir', 'my_acf_settings_dir'); function my_acf_settings_dir( $dir ) { // update path $dir = plugins_url() . '/simple/acf/'; // homecoming homecoming $dir; }

php wordpress shared-hosting advanced-custom-fields dirname

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -