vendor/devowl-wp/deliver-anonymous-asset/src/DeliverAnonymousAsset.php
:
/**
* Get the content directory URL.
*/
public static function getContentUrl()
{
return \trailingslashit(\set_url_scheme(\constant('WP_CONTENT_URL')));
}
/**
* Get the content directory and also ensure it is created.
*
* @return string|false Returns false
if the folder could not be created.
*/
public static function getContentDir()
{
$folder = \constant('WP_CONTENT_DIR') . '/';
/**
* Get the content directory where anonymous assets should be placed.
*
* @hook DevOwl/DeliverAnonymousAsset/ContentDir
* @param {string} $folder
* @return {string}
*/
$folder = \apply_filters('DevOwl/DeliverAnonymousAsset/ContentDir', $folder);
if (!\wp_is_writable($folder)) {
return \false;
}
return $folder;
}
Tested in Real Cookie Banner v3.7.2
]]>I am trying to use @wordpress/hooks within my 2 plugins. Here the scenario what i wanted to do.
I am using react routing within my 1st plugin in which i am using applyFilters
so that new routing can be added from the 2nd plugin.
Here the code what i am using to add routes dynamically in my 1st plugin.
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import { applyFilters } from '@wordpress/hooks';
import store from './store';
import Home from './components/body/tabs/home/home.jsx';
import Customer from './components/body/tabs/customer/customer.jsx';
import wkwcpos_variable from './config';
export const PAGES_FILTER = 'wkwcpos_pages_list';
export function getPages() {
const pages = [
{
name: 'Customers',
path: '/pos/customers',
component: Customer
},
{
name: 'Home',
path: '/pos',
component: Home
}
];
return applyFilters( PAGES_FILTER, pages );
}
document.addEventListener("DOMContentLoaded", () => {
ReactDOM.render(
<Provider store={store}>
<BrowserRouter>
<Switch>
{ getPages().map( page => {
return (
<Route
key={ wkwcpos_variable.HOME_URL + page.path }
path={ wkwcpos_variable.HOME_URL + page.path }
exact
name = { page.name }
component={ page.component }
/>
);
} ) }
</Switch>
</BrowserRouter>
</Provider>
,document.getElementById('app'));
});
But when I add new route with my 2nd plugin and add code component from that plugin, it throws an error to provide the store for it. But i need to use the store of 1st plugin inside my 2nd plugin.
import React from 'react';
import { addFilter } from '@wordpress/hooks';
import Booking from './components/body/tabs/booking/booking.jsx';
addFilter( 'wkwcpos_pages_list', 'plugin-domain', pages => {
return [
...pages,
{
name: 'Booking',
path: '/pos/booking',
component: Booking
}
];
} );
Here is the booking component,
import React, { Component } from 'react';
import { connect } from 'react-redux';
import Product from './product/product.jsx';
import './less/booking.less';
class Booking extends Component {
constructor(props) {
super(props);
}
render() {
var products = this.props.products;
var listProducts = '';
if( products.length > 0 ) {
listProducts = products.map( ( element, i ) => {
return (
<Product key={i} product={element}></Product>
);
});
}
return (
<div className="body-wrap">
{listProducts}
</div>
);
}
}
const mapStateToProps = state => ({
products: state.products
});
export default connect( mapStateToProps )(Booking);
Here i need to use the state defined in the 1st plugin. Can anyone help me in this?
]]>I am trying to use @wordpress/hooks within my 2 plugins. Here the scenario what i wanted to do.
I am using react routing within my 1st plugin in which i am using applyFilters
so that new routing can be added from the 2nd plugin.
Here the code what i am using to add routes dynamically in my 1st plugin.
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import { applyFilters } from '@wordpress/hooks';
import store from './store';
import Home from './components/body/tabs/home/home.jsx';
import Customer from './components/body/tabs/customer/customer.jsx';
import wkwcpos_variable from './config';
export const PAGES_FILTER = 'wkwcpos_pages_list';
export function getPages() {
const pages = [
{
name: 'Customers',
path: '/pos/customers',
component: Customer
},
{
name: 'Home',
path: '/pos',
component: Home
}
];
return applyFilters( PAGES_FILTER, pages );
}
document.addEventListener("DOMContentLoaded", () => {
ReactDOM.render(
<Provider store={store}>
<BrowserRouter>
<Switch>
{ getPages().map( page => {
return (
<Route
key={ wkwcpos_variable.HOME_URL + page.path }
path={ wkwcpos_variable.HOME_URL + page.path }
exact
name = { page.name }
component={ page.component }
/>
);
} ) }
</Switch>
</BrowserRouter>
</Provider>
,document.getElementById('app'));
});
But when I add new route with my 2nd plugin and add code component from that plugin, it throws an error to provide the store for it. But i need to use the store of 1st plugin inside my 2nd plugin.
import React from 'react';
import { addFilter } from '@wordpress/hooks';
import Booking from './components/body/tabs/booking/booking.jsx';
addFilter( 'wkwcpos_pages_list', 'plugin-domain', pages => {
return [
...pages,
{
name: 'Booking',
path: '/pos/booking',
component: Booking
}
];
} );
Here is the booking component,
import React, { Component } from 'react';
import { connect } from 'react-redux';
import Product from './product/product.jsx';
import './less/booking.less';
class Booking extends Component {
constructor(props) {
super(props);
}
render() {
var products = this.props.products;
var listProducts = '';
if( products.length > 0 ) {
listProducts = products.map( ( element, i ) => {
return (
<Product key={i} product={element}></Product>
);
});
}
return (
<div className="body-wrap">
{listProducts}
</div>
);
}
}
const mapStateToProps = state => ({
products: state.products
});
export default connect( mapStateToProps )(Booking);
Here i need to use the state defined in the 1st plugin. Can anyone help me in this?
]]>I would like to know about @wordpress/hooks use. As using this package we can add hooks for filters and actions. These added hooks can be used within same react application. But, how to use these hooks from different react applications.
Any kind of information regarding above will be appreciated.
Thanks & Regards
]]>I have an application in cakePHP i need to get all wordpress themes from the api and activate and deactivate those from the cakephp panel through the api.
Is it possible? if possible then how i can do that?
Any help will be appreciated.
Thanks
Krishna
If some one find solution for comment hook ,reply me
]]>I need to run a bunch of GDlib processing on JUST the new image size I have created and named using the WordPress hooks. For sake of discussion I used add_image_size(‘google-marker’,100,100, false);
Now I dont want to change anything about the other files WordPress creates based on the media settings. I just want to change ‘google-marker’ to have a border and a little arrow pointer (which I know how to do in GDlib already)… I just dont know how to hook into wordpress to intercept the default image resizing and create my own.
Any pointers, help, links for things similer etc are all much appreciated.
Cheers
]]>My goal is to then tie it into WordPress.
Thank you,
-Eric
At a very high level my requirement is
1 Add a custom button ( let’s call it MyButton) in tinyMCE editor toolbar.
2 Click on the button should open a new popup div/window.
I tried this code,But unable to add my custom button.
function add_more_buttons($buttons) {
$buttons[] = 'hr';
$buttons[] = 'del';
$buttons[] = 'cut';
$buttons[] = 'sup';
$buttons[] = 'MyButton'; // Want to add my custom button
return $buttons;
}
add_filter("mce_buttons_2", "add_more_buttons");
Anyone having any idea???
]]>