Comments (3)
Solve the problem by adding
Action::listen('admin_head', $this, 'install')->dispatch();
in plugins/themosis-framework/src/Themosis/Ajax/Ajax.php line 30
but maybe itβs not good to change the source code of framework..
from framework.
In order to keep the source by framework.
Also solve the problem by adding this to php files in app/admin/
/** AdminAjax **/
if(!class_exists('AdminAjax')){
class AdminAjax{
private $namespace;
private $url;
public function __construct(){
$this->namespace = (Application::get('namespace')) ? Application::get('namespace') : 'themosis';
$this->url = (Application::get('ajaxurl')) ? admin_url().Application::get('ajaxurl').'.php' : '';
add_action( "admin_head" , array($this,'install') );
}
public function install()
{
$datas = apply_filters('themosisGlobalObject', array());
$ajaxurl = array(
'ajaxurl' => $this->url
);
$namespace = array_merge($ajaxurl, $datas);
$namespace = json_encode($namespace);
$output = "<script type=\"text/javascript\">\n\r";
$output.= "//<![CDATA[\n\r";
$output.= "var ".$this->namespace." = ".$namespace;
$output.= "//]]>\n\r";
$output.= "</script>";
echo($output);
}
}
if(is_admin()){
new AdminAjax();
}
}
from framework.
Hi,
there is no need for all this code :) By default, WordPress admin has a global JS variable called ajaxurl
. Inspect the top of the <head> tag.
Also, there is already a Themosis framework global JS object available in the admin which is totally different than the one for the front-end.
The admin global JS can't be renamed. You can add key/values to it by using this filter:
add_filter('themosisAdminGlobalObject', function($data)
{
return $data['key'] = 'Some value';
});
Then use it for your admin script like so:
var foo = thfmk_themosis.key;
Hope this helps. I will add these info in the docs ;)
from framework.
Related Issues (20)
- Class DateField missing
- Metabox Field rules error message not showing up HOT 3
- Test (phpunit) has no access to config HOT 3
- Oddity in the Form handleRequest method HOT 7
- Trait 'Themosis\Core\Events\Dispatchable' not found HOT 1
- Themosis throws ErrorException for deprecations HOT 2
- themosis stores the node folder in the database HOT 2
- Defining routes to a controller, Reflection errors HOT 3
- Php artisan don't working after upgrade HOT 5
- Custom prefix routes in RouteServiceProvider.php
- User can directly access the theme directory
- Publish problem HOT 4
- Route controller declaration using array syntax
- Problem with connection after "vagrant up" command HOT 1
- Class FatalThrowableError not found
- Easy way to create Gutenberg blocks
- Wrong Twig Template Loading Order (App vs. Theme)
- Class \"Illuminate\\Foundation\\Bus\\PendingChain\" not found HOT 3
- Properly way to use form class and AJAX class
- Route using template not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from framework.