attach_ajax_actions();
FW_Option_Type::register( 'FW_Option_Type_Icon_v2' );
}
{
FW_Option_Type::register( 'FW_Option_Type_Multi_Select' );
}
{
FW_Option_Type::register( 'FW_Option_Type_Oembed' );
}
}
add_action( 'fw_option_types_init', '_action_fw_init_option_types' );
/**
* Some option-types have add_action('wp_ajax_...')
* so init all option-types if current request is ajax
* @since 2.6.1
*/
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
function _action_fw_init_option_types_on_ajax() {
foreach (fw()->backend->get_option_types() as $type) {
fw()->backend->option_type($type);
}
}
add_action( 'fw_init', '_action_fw_init_option_types_on_ajax' );
}
/**
* Prevent Fatal Error if someone is registering option-types in old way (right away)
* not in 'fw_option_types_init' action
*
* @param string $class
*/
function _fw_autoload_option_types( $class ) {
if ( 'FW_Option_Type' === $class ) {
if ( is_admin() && defined( 'WP_DEBUG' ) && WP_DEBUG ) {
FW_Flash_Messages::add(
'option-type-register-wrong',
__( "Please register option-types on 'fw_option_types_init' action", 'fw' ),
'warning'
);
}
} elseif ( 'FW_Container_Type' === $class ) {
if ( is_admin() && defined( 'WP_DEBUG' ) && WP_DEBUG ) {
FW_Flash_Messages::add(
'container-type-register-wrong',
__( "Please register container-types on 'fw_container_types_init' action", 'fw' ),
'warning'
);
}
}
}
spl_autoload_register( '_fw_autoload_option_types' );
}
/**
* Container types
*/
{
/**
* @internal
*/
function _action_fw_init_container_types() {
FW_Container_Type::register( 'FW_Container_Type_Group' );
FW_Container_Type::register( 'FW_Container_Type_Box' );
FW_Container_Type::register( 'FW_Container_Type_Popup' );
FW_Container_Type::register( 'FW_Container_Type_Tab' );
}
add_action( 'fw_container_types_init', '_action_fw_init_container_types' );
}
/**
* Custom Github API service
* Provides the same responses but is "unlimited"
* To prevent error: Github API rate limit exceeded 60 requests per hour
* https://github.com/ThemeFuse/Unyson/issues/138
* @internal
*/
function _fw_filter_github_api_url( $url ) {
return 'https://github-api-cache.unyson.io';
}
add_filter( 'fw_github_api_url', '_fw_filter_github_api_url' );
/**
* Javascript events related to tinymce init
* @since 2.6.0
*/
{
add_action( 'wp_tiny_mce_init', '_fw_action_tiny_mce_init' );
function _fw_action_tiny_mce_init( $mce_settings ) {
?>
is_valid() ) {
return;
}
foreach ( $form->get_errors() as $input_name => $error_message ) {
FW_Flash_Messages::add( 'fw-form-admin-' . $input_name, $error_message, 'error' );
}
}
add_action( 'wp_loaded', '_action_fw_form_show_errors_in_admin', 111 );
} else {
/**
* to disable this use remove_action('wp_print_styles', '_action_fw_form_frontend_default_styles');
* @internal
*/
function _action_fw_form_frontend_default_styles() {
$form = FW_Form::get_submitted();
if ( ! $form || $form->is_valid() ) {
return;
}
echo '';
}
add_action( 'wp_print_styles', '_action_fw_form_frontend_default_styles' );
}
}
// FW_Flash_Messages hooks
{
if ( is_admin() ) {
/**
* Start the session before the content is sent to prevent the "headers already sent" warning
* @internal
*/
function _action_fw_flash_message_backend_prepare() {
if ( apply_filters( 'fw_use_sessions', true ) && ! session_id() ) {
session_start();
}
}
add_action( 'current_screen', '_action_fw_flash_message_backend_prepare', 9999 );
/**
* Display flash messages in backend as notices
*/
add_action( 'admin_notices', array( 'FW_Flash_Messages', '_print_backend' ) );
} else {
/**
* Start the session before the content is sent to prevent the "headers already sent" warning
* @internal
*/
function _action_fw_flash_message_frontend_prepare() {
if (
apply_filters( 'fw_use_sessions', true )
&&
/**
* In ajax it's not possible to call flash message after headers were sent,
* so there will be no "headers already sent" warning.
* Also in the Backups extension, are made many internal ajax request,
* each creating a new independent request that don't remember/use session cookie from previous request,
* thus on server side are created many (not used) new sessions.
*/
! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
&&
! session_id()
) {
session_start();
}
}
add_action( 'send_headers', '_action_fw_flash_message_frontend_prepare', 9999 );
/**
* Print flash messages in frontend if this has not been done from theme
*/
function _action_fw_flash_message_frontend_print() {
if ( FW_Flash_Messages::_frontend_printed() ) {
return;
}
if ( ! FW_Flash_Messages::_print_frontend() ) {
return;
}
?>