function __construct() { if (is_admin()) { // common things to run upon init here if (isset($_GET['page']) && ($_GET['page'] == WPDDL_LAYOUTS_POST_TYPE || $_GET['page'] == 'dd_layouts_edit')) { do_action('ddl-wpml-switcher-scripts'); } $this->layouts_settings = WPDDL_Settings::getInstance(); // init gui for settings $this->layouts_settings->init(); // Include "Settings" admin menu add_action('admin_menu', array($this, 'add_layouts_settings_admin_menu'), 11); } }
function __construct() { self::$MAX_NUM_POSTS = WPDDL_Settings::get_max_posts_num(); $this->layout_id = isset($_GET['layout_id']) ? $_GET['layout_id'] : null; global $post; $post = $post ? $post : get_post($this->layout_id); $this->post = $post; if (isset($_GET['page']) and $_GET['page'] == 'dd_layouts_edit') { remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('wp_print_styles', 'print_emoji_styles'); if ($this->post === null) { add_action('admin_enqueue_scripts', array($this, 'preload_styles')); add_action('wpddl_layout_not_found', array($this, 'layout_not_found'), 10); return; } $this->clean_orphaned_cells(null); add_action('wpddl_pre_render_editor', array($this, 'pre_render_editor'), 10, 1); add_action('wpddl_render_editor', array($this, 'render_editor'), 10, 1); add_action('wpddl_after_render_editor', array($this, 'after_render_editor'), 10, 1); //add_action('wpddl_after_render_editor', array($this,'print_where_used_links'), 11, 1); add_action('wpddl_after_render_editor', array($this, 'add_empty_where_used_ui'), 11, 1); add_action('wpddl_after_render_editor', array($this, 'add_video_toolbar'), 11, 1); add_action('wpddl_after_render_editor', array($this, 'add_wpml_ui'), 12, 1); add_action('wpddl_layout_actions', array($this, 'layout_actions')); add_action('admin_enqueue_scripts', array($this, 'preload_styles')); add_action('admin_enqueue_scripts', array($this, 'preload_scripts')); add_action('admin_init', array($this, 'init_editor')); //add_action('admin_enqueue_scripts', array($this, 'load_latest_backbone'), -1000); do_action('wpddl_layout_actions'); } //leave wp_ajax out of the **** otherwise it won't be fired add_action('wp_ajax_get_layout_data', array(&$this, 'get_layout_data_callback')); add_action('wp_ajax_save_layout_data', array(&$this, 'save_layout_data_callback')); add_action('wp_ajax_get_layout_parents', array(&$this, 'get_layout_parents_callback')); add_action('wp_ajax_check_for_parents_loop', array(&$this, 'check_for_parents_loop_callback')); add_action('wp_ajax_check_for_parent_child_layout_width', array(&$this, 'check_for_parent_child_layout_width_callback')); add_action('wp_ajax_view_layout_from_editor', array(&$this, 'view_layout_from_editor_callback')); add_action('wp_ajax_show_all_posts', array(&$this, 'show_all_posts_callback')); add_action('wp_ajax_ddl_get_where_used_ui', array(&$this, 'get_where_used_ui_callback')); add_action('wp_ajax_edit_layout_slug', array(&$this, 'edit_layout_slug_callback')); add_action('wp_ajax_remove_all_layout_associations', array(&$this, 'remove_all_layout_associations_callback')); add_action('wp_ajax_ddl_update_wpml_state', array(&$this, 'update_wpml_state')); add_action('wp_ajax_ddl_load_assign_dialog_editor', array(&$this, 'load_assign_dialog_callback')); add_action('wp_ajax_ddl_compact_display_mode', array(&$this, 'compact_display_callback')); add_filter('ddl_layout_settings_save', array(&$this, 'settings_save_callback'), 10, 3); }
public static function ddl_set_max_posts_amount() { if (user_can_edit_layouts() === false) { die(WPDD_Utils::ajax_caps_fail(__METHOD__)); } if ($_POST && wp_verify_nonce($_POST['ddl_max-posts-num_nonce'], 'ddl_max-posts-num_nonce')) { $update = false; $amount = isset($_POST['amount_posts']) ? $_POST['amount_posts'] : self::$max_posts_num_option; if ($amount !== self::$max_posts_num_option) { self::$max_posts_num_option = $amount; $update = self::set_option_max_num_posts($amount); } if ($update) { $send = wp_json_encode(array('Data' => array('message' => __('Updated option', 'ddl-layouts'), 'amount' => $amount))); } else { $send = wp_json_encode(array('Data' => array('error' => __('Option not updated', 'ddl-layouts'), 'amount' => $amount))); } } else { $send = wp_json_encode(array('error' => __(sprintf('Nonce problem: apparently we do not know where the request comes from. %s', __METHOD__), 'ddl-layouts'))); } die($send); }