function init() { $this->wpv_register_type_view(); $this->plugin_localization(); add_action('wp_ajax_wpv_get_type_filter_summary', 'wpv_ajax_get_type_filter_summary'); add_action('wp_ajax_wpv_get_table_row_ui', array($this, 'ajax_get_table_row_ui')); add_action('wp_ajax_wpv_add_custom_field', 'wpv_ajax_add_custom_field'); add_action('wp_ajax_wpv_add_taxonomy', 'wpv_ajax_add_taxonomy'); add_action('wp_ajax_wpv_pagination', 'wpv_ajax_pagination'); add_action('wp_ajax_wpv_views_editor_height', array($this, 'save_editor_height')); add_action('wp_ajax_wpv_get_posts_select', 'wpv_get_posts_select'); add_action('wp_ajax_wpv_dismiss_message', array($this, 'wpv_dismiss_message')); add_action('wp_ajax_wpv_get_taxonomy_parents_select', 'wpv_get_taxonomy_parents_select'); add_action('wp_ajax_wpv_get_taxonomy_term_check', 'wpv_get_taxonomy_term_check'); add_action('wp_ajax_wpv_get_taxonomy_term_summary', 'wpv_ajax_get_taxonomy_term_summary'); add_action('wp_ajax_wpv_get_post_relationship_info', 'wpv_ajax_wpv_get_post_relationship_info'); add_action('wp_ajax_wpv_view_form_popup', 'wpv_ajax_wpv_view_form_popup'); add_action('wp_ajax_wpv_insert_form_shortcode', 'wp_ajax_wpv_insert_form_shortcode'); add_action('wp_ajax_wpv_get_show_hidden_custom_fields', array($this, 'wpv_get_show_hidden_custom_fields')); add_action('wp_ajax_wpv_format_date', array($this, 'wpv_format_date')); add_action('wp_ajax_nopriv_wpv_format_date', array($this, 'wpv_format_date')); add_action('wp_ajax_wpv_save_theme_debug_settings', array($this, 'wpv_save_theme_debug_settings')); add_action('wp_ajax_wpv_view_media_manager', array($this, 'wp_ajax_wpv_view_media_manager')); if (is_admin()) { if (function_exists('wpv_admin_menu_import_export_hook')) { add_action('wp_loaded', 'wpv_admin_menu_import_export_hook'); } add_action('admin_menu', array($this, 'admin_menu')); add_action('admin_head', array($this, 'settings_box_load')); add_action('admin_footer', array($this, 'hide_view_body_controls')); add_action('save_post', array($this, 'save_view_settings')); //add_action('save_post', array($this, 'save_css')); global $pagenow; if ($pagenow == 'post.php' || $pagenow == 'post-new.php') { add_action('admin_head', array($this, 'post_edit_tinymce')); add_action('admin_head', array($this, 'add_css')); add_action('admin_print_scripts', array($this, 'add_js')); add_action('icl_post_languages_options_after', array($this, 'language_options')); add_action('admin_head', array($this, 'set_editor_height')); } global $wp_version; if (version_compare($wp_version, '3.3', '<')) { add_filter('contextual_help', array($this, 'admin_plugin_help'), 10, 3); } promote_types_and_views(); } else { // Add pagination for the front end. wp_enqueue_script('views-pagination-script', WPV_URL_EMBEDDED . '/res/js/wpv-pagination-embedded.js', array('jquery'), WPV_VERSION); wp_enqueue_style('views-pagination-style', WPV_URL_EMBEDDED . '/res/css/wpv-pagination.css', array(), WPV_VERSION); wp_enqueue_script('jquery-ui-datepicker', WPV_URL_EMBEDDED . '/res/js/jquery.ui.datepicker.min.js', array('jquery-ui-core', 'jquery'), WPV_VERSION); $lang = get_locale(); $lang = str_replace('_', '-', $lang); if (file_exists(WPV_PATH_EMBEDDED . '/res/js/i18n/jquery.ui.datepicker-' . $lang . '.js')) { wp_enqueue_script('jquery-ui-datepicker-local', WPV_URL_EMBEDDED . '/res/js/i18n/jquery.ui.datepicker-' . $lang . '.js', array('jquery-ui-core', 'jquery', 'jquery-ui-datepicker'), WPV_VERSION); } else { $lang = substr($lang, 0, 2); if (file_exists(WPV_PATH_EMBEDDED . '/res/js/i18n/jquery.ui.datepicker-' . $lang . '.js')) { wp_enqueue_script('jquery-ui-datepicker-local', WPV_URL_EMBEDDED . '/res/js/i18n/jquery.ui.datepicker-' . $lang . '.js', array('jquery-ui-core', 'jquery', 'jquery-ui-datepicker'), WPV_VERSION); } } //wp_enqueue_style( 'date-picker-style' , WPV_URL_EMBEDDED . '/res/css/datepicker.css', array(), WPV_VERSION); wp_enqueue_script('wpv-date-front-end-script', WPV_URL_EMBEDDED . '/res/js/wpv-date-front-end-control.js', array('jquery'), WPV_VERSION); add_action('wp_head', 'wpv_add_front_end_js'); add_action('wp_footer', array($this, 'wpv_meta_html_extra')); } /*shorttags*/ add_shortcode('wpv-view', array($this, 'short_tag_wpv_view')); add_shortcode('wpv-form-view', array($this, 'short_tag_wpv_view_form')); add_action('wp_print_styles', array($this, 'add_render_css')); add_filter('edit_post_link', array($this, 'edit_post_link'), 10, 2); // check for views import. global $wpv_theme_import, $wpv_theme_import_xml; if (isset($wpv_theme_import) && $wpv_theme_import != '') { include $wpv_theme_import; $dismissed = get_option('views_dismissed_messages', array()); if (!in_array($timestamp, $dismissed)) { if ($timestamp > get_option('views-embedded-import', 0)) { // something new to import. if ($auto_import) { if (!isset($_POST['import'])) { // setup an automatic import $_POST['import'] = __('Import', 'wpv-views'); $_POST['wpv-import-nonce'] = wp_create_nonce('wpv-import-nonce'); $_POST['views-overwrite'] = 'on'; $_POST['view-templates-overwrite'] = 'on'; $_POST['import-file'] = $wpv_theme_import_xml; } } else { global $pagenow; if ($pagenow != 'options-general.php' || !isset($_GET['page']) || $_GET['page'] != 'wpv-import-theme') { // add admin message about importing. $link = '<a href=\\"' . admin_url('options-general.php') . '?page=wpv-import-theme\\">'; $text = sprintf(__('You have <strong>Views</strong> import pending. %sClick here to import.%s %sDismiss message.%s', 'wpcf'), $link, '</a>', '<a onclick=\\"jQuery(this).parent().parent().fadeOut();\\" href=\\"' . admin_url('admin-ajax.php?action=wpv_dismiss_message&id=' . $timestamp . '&wpv_nonce=' . wp_create_nonce('wpv-dismiss-message')) . '\\">', '</a>'); $code = 'echo "<div class=\\"message updated\\"><p>' . $text . '</p></div>";'; add_action('admin_notices', create_function('$a=1', $code)); } } } } add_action('admin_menu', array($this, 'add_import_menu')); } }
function init() { $this->wpv_register_type_view(); $this->plugin_localization(); if (is_admin()) { add_action('admin_enqueue_scripts', array($this, 'wpv_admin_enqueue_scripts')); } add_action('wp_ajax_wpv_get_type_filter_summary', 'wpv_ajax_get_type_filter_summary'); add_action('wp_ajax_wpv_get_table_row_ui', array($this, 'ajax_get_table_row_ui')); add_action('wp_ajax_wpv_add_custom_field', 'wpv_ajax_add_custom_field'); add_action('wp_ajax_wpv_add_taxonomy', 'wpv_ajax_add_taxonomy'); add_action('wp_ajax_wpv_pagination', 'wpv_ajax_pagination'); add_action('wp_ajax_wpv_views_editor_height', array($this, 'save_editor_height')); add_action('wp_ajax_wpv_get_posts_select', 'wpv_get_posts_select'); add_action('wp_ajax_wpv_dismiss_message', array($this, 'wpv_dismiss_message')); add_action('wp_ajax_wpv_get_taxonomy_parents_select', 'wpv_get_taxonomy_parents_select'); add_action('wp_ajax_wpv_get_taxonomy_term_check', 'wpv_get_taxonomy_term_check'); add_action('wp_ajax_wpv_get_taxonomy_term_summary', 'wpv_ajax_get_taxonomy_term_summary'); add_action('wp_ajax_wpv_get_post_relationship_info', 'wpv_ajax_wpv_get_post_relationship_info'); // AJAX calls to insert View forms shortcodes add_action('wp_ajax_wpv_view_form_popup', 'wpv_ajax_wpv_view_form_popup'); // AJAX calls to insert Translatable String shortcodes add_action('wp_ajax_wpv_translatable_string_popup', 'wpv_ajax_wpv_translatable_string_popup'); // AJAX calls for the Settings page add_action('wp_ajax_wpv_save_theme_debug_settings', array($this, 'wpv_save_theme_debug_settings')); add_action('wp_ajax_wpv_save_wpml_settings', array($this, 'wpv_save_wpml_settings')); add_action('wp_ajax_wpv_get_show_hidden_custom_fields', array($this, 'wpv_get_show_hidden_custom_fields')); add_action('wp_ajax_wpv_update_custom_inner_shortcodes', array($this, 'wpv_update_custom_inner_shortcodes')); add_action('wp_ajax_wpv_update_map_plugin_status', array($this, 'wpv_update_map_plugin_status')); add_action('wp_ajax_wpv_update_debug_mode_status', array($this, 'wpv_update_debug_mode_status')); add_action('wp_ajax_wpv_switch_debug_check', array($this, 'wpv_switch_debug_check')); // AJAX calls for date filters add_action('wp_ajax_wpv_format_date', array($this, 'wpv_format_date')); add_action('wp_ajax_nopriv_wpv_format_date', array($this, 'wpv_format_date')); add_action('wp_ajax_wpv_view_media_manager', array($this, 'wp_ajax_wpv_view_media_manager')); // NOTE this should be DEPRECATED if (is_admin()) { if (function_exists('wpv_admin_menu_import_export_hook')) { add_action('wp_loaded', 'wpv_admin_menu_import_export_hook'); } add_action('admin_menu', array($this, 'admin_menu')); add_action('admin_head', array($this, 'settings_box_load')); add_action('admin_footer', array($this, 'hide_view_body_controls')); add_action('save_post', array($this, 'save_view_settings')); global $pagenow; if ($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'admin.php' && isset($_GET['page']) && $_GET['page'] == 'dd_layouts_edit') { add_action('admin_head', array($this, 'post_edit_tinymce')); add_action('admin_head', array($this, 'add_css')); // TODO DEPRECATED this is not used anymore add_action('admin_print_scripts', array($this, 'add_js')); // TODO DEPRECATED this is not used anymore add_action('icl_post_languages_options_after', array($this, 'language_options')); add_action('admin_head', array($this, 'set_editor_height')); } global $wp_version; if (version_compare($wp_version, '3.3', '<')) { add_filter('contextual_help', array($this, 'admin_plugin_help'), 10, 3); } promote_types_and_views(); // Add action to be executed on plugins_loaded in Views taxonomy-related View loops admin GUIs add_filter('wpv_admin_exclude_tax_slugs', 'wpv_admin_exclude_tax_slugs'); } else { // Add scripts and styles to the frontend add_action('wp_enqueue_scripts', array($this, 'wpv_frontend_enqueue_scripts')); add_action('wp_head', 'wpv_add_front_end_js'); add_action('wp_footer', array($this, 'wpv_meta_html_extra_css'), 5); // Set priority lower than 20, so we load the CSS before the footer scripts and avoid the bottleneck add_action('wp_footer', array($this, 'wpv_meta_html_extra_js'), 25); // Set priority higher than 20, when all the footer scripts are loaded } /*shorttags*/ add_shortcode('wpv-view', array($this, 'short_tag_wpv_view')); add_shortcode('wpv-form-view', array($this, 'short_tag_wpv_view_form')); add_filter('edit_post_link', array($this, 'edit_post_link'), 10, 2); // check for views import. global $wpv_theme_import, $wpv_theme_import_xml; if (isset($wpv_theme_import) && $wpv_theme_import != '') { include $wpv_theme_import; $dismissed = get_option('views_dismissed_messages', array()); if (!in_array($timestamp, $dismissed)) { if ($timestamp > get_option('views-embedded-import', 0)) { // something new to import. if ($auto_import) { if (!isset($_POST['import'])) { // setup an automatic import $_POST['import'] = __('Import', 'wpv-views'); $_POST['wpv-import-nonce'] = wp_create_nonce('wpv-import-nonce'); $_POST['views-overwrite'] = 'on'; $_POST['view-templates-overwrite'] = 'on'; $_POST['import-file'] = $wpv_theme_import_xml; } } else { global $pagenow; if ($pagenow != 'options-general.php' || !isset($_GET['page']) || $_GET['page'] != 'wpv-import-theme') { // add admin message about importing. $link = '<a href=\\"' . admin_url('options-general.php') . '?page=wpv-import-theme\\">'; $text = sprintf(__('You have <strong>Views</strong> import pending. %sClick here to import.%s %sDismiss message.%s', 'wpcf'), $link, '</a>', '<a onclick=\\"jQuery(this).parent().parent().fadeOut();\\" href=\\"' . admin_url('admin-ajax.php?action=wpv_dismiss_message&id=' . $timestamp . '&wpv_nonce=' . wp_create_nonce('wpv-dismiss-message')) . '\\">', '</a>'); $code = 'echo "<div class=\\"message updated\\"><p>' . $text . '</p></div>";'; add_action('admin_notices', create_function('$a=1', $code)); } } } } add_action('admin_menu', array($this, 'add_import_menu')); // TODO check where we put this } }