예제 #1
0
    public function init()
    {
        parent::init();
        $tax_name = $this->config['tax'];
        $print_hook = array("{$tax_name}_edit_form_fields");
        $save_hook = array("edited_{$tax_name}");
        if (!isset($this->config['remove_create_form']) || empty($this->config['remove_create_form'])) {
            $print_hook[] = "{$tax_name}_add_form_fields";
            $save_hook[] = "create_{$tax_name}";
        }
        foreach ($print_hook as $hook) {
            add_action($hook, array($this, 'setup_print'), 10, 1);
        }
        foreach ($save_hook as $hook) {
            add_action($hook, array($this, 'submit'), 10, 3);
        }
        if ($this->config['remove_default_desc']) {
            add_action('admin_head', function () use($tax_name) {
                $screen = get_current_screen();
                if (!in_array($screen->id, array('edit-' . $tax_name, 'add-' . $tax_name))) {
                    return;
                }
                echo '<style>
					.term-description-wrap { display: none; } 
				</style>';
            });
        }
    }
 /**
  * Init PRINT and SUBMIT hooks.
  */
 public function init()
 {
     // Init fields etc.
     parent::init();
     // Print
     add_action($this->config['hooks']['print'], array($this, 'print_form'));
     // Submit
     add_action('admin_post_nopriv_' . $this->config['hooks']['submit'], array($this, 'submit'));
     add_action('admin_post_' . $this->config['hooks']['submit'], array($this, 'submit'));
     if (!empty($this->config['templates']['session'])) {
         \Cibulka::Base('register_session_var', 'cibulka_form', $this->config['templates']['session']);
     }
     /*
     $i = 1;
     add_filter('wp_redirect_status', function($status, $location) use ($i) {
     	if ($i > 1) {
     		\Cibulka\dump("redirect loop?");
     	}
     	update_option($status, $location);
     	$i++;
     	return $status;
     }, 11, 2);
     */
 }
예제 #3
0
 public function init()
 {
     parent::init();
     add_action('add_meta_boxes', array($this, 'setup_print'), 10, 2);
     add_action('save_post', array($this, 'submit'), 10, 3);
     add_action('save_post', array($this, 'submit_extra'), 11, 3);
     foreach ((array) $this->config['remove_tax'] as $tax) {
         foreach ((array) $this->config['post_type'] as $post_type) {
             $tax_1 = 'tagsdiv-' . $tax;
             add_action('admin_menu', function () use($tax_1, $post_type) {
                 remove_meta_box($tax_1, $post_type, 'side');
             }, $post_type);
             $tax_2 = $tax . 'div';
             add_action('admin_menu', function () use($tax_2, $post_type) {
                 remove_meta_box($tax_2, $post_type, 'side');
             }, $post_type);
         }
     }
     if ($this->config['remove_default_excerpt']) {
         add_action('admin_menu', function () {
             remove_meta_box('postexcerpt', $this->config['post_type'], 'normal');
         });
     }
 }
예제 #4
0
    public function init()
    {
        parent::init();
        add_action('show_user_profile', array($this, 'setup_print'), 9, 1);
        add_action('edit_user_profile', array($this, 'setup_print'), 9, 1);
        add_action('personal_options_update', array($this, 'submit'), 10, 1);
        add_action('edit_user_profile_update', array($this, 'submit'), 10, 1);
        if ($this->config['remove_personal_options']) {
            remove_action('admin_color_scheme_picker', 'admin_color_scheme_picker');
        }
        if ($this->config['remove_about']) {
            add_action('admin_head', function () {
                // die(get_current_screen()->id);
                if (!in_array(get_current_screen()->id, array('user-edit', 'profile'))) {
                    return;
                }
                echo '<style>
					.user-rich-editing-wrap,
					.user-comment-shortcuts-wrap,
					.user-profile-picture,
					.user-description-wrap,
					.user-admin-bar-front-wrap,
					.user-first-name-wrap,
					.user-last-name-wrap,
					.user-nickname-wrap,
					.user-display-name-wrap,
					.user-url-wrap,
					#your-profile h2:nth-of-type(-n+5) { display: none;}
				</style>';
            });
            /*
            			add_action('personal_options', function() {
            				$action = (IS_PROFILE_PAGE ? 'show' : 'edit') . '_user_profile';
            				add_action( $action, function() {
            $html = ob_get_contents();
            ob_end_clean();
            
            $dom = \Cibulka::Base('DOMDocument');
            $dom->loadHTML($html);
            $dom->remove_elements_by_classname("tr", "user-profile-picture");
            $dom->remove_elements_by_classname("tr", "user-description-wrap");
            
            print $dom->get_content();
            
            /*
            $headline = __( IS_PROFILE_PAGE ? 'About Yourself' : 'About the user' );
            $html = str_replace( '<h3>' . $headline . '</h3>', '', $html );
            $html = preg_replace( '~<tr class="user-profile-picture">.*</tr>~imsUu', '', $html );
            $html = preg_replace( '~<tr class="user-description-wrap">\s*<th><label for="description".*</tr>~imsUu', '', $html );
            */
            // });
            // ob_start();
            // });
            /*
            add_action('admin_head', function() {
            
            	// \Cibulka\dump(get_current_screen());
            	if (!in_array(get_current_screen()->id, array('profile', 'user-edit'))) { return; }
            
            	ob_start(function($html) {
            		$dom = \Cibulka::Base('DOMDocument');
            		$dom->loadHTML($html);
            		$dom->limit_to_id("div", "wpwrap");
            		
            		// Personal info
            		$dom->remove_elements_by_classname("tr", "user-rich-editing-wrap");
            		$dom->remove_elements_by_classname("tr", "user-comment-shortcuts-wrap");
            		$dom->remove_elements_by_classname("tr", "user-admin-bar-front-wrap");
            		// Name
            		$dom->remove_elements_by_classname("tr", "user-first-name-wrap");
            		$dom->remove_elements_by_classname("tr", "user-last-name-wrap");
            		// Contact info
            		$dom->remove_elements_by_classname("tr", "user-url-wrap");
            		// About Yourself
            		$dom->remove_elements_by_classname("tr", "user-display-name-wrap");
            		$dom->remove_elements_by_classname("tr", "user-profile-picture");
            		$dom->remove_elements_by_classname("tr", "user-description-wrap");
            		// Remove h2
            		$dom->remove_elements_by_tagname("h2");
            		// RETURN
            		
            		$result = $dom->get_content();
            		$result = str_replace('<h2>About the user</h2>', '', $result);
            		return $result;
            
            	});
            
            
            });
            
            
            add_action('admin_footer', function() {
            	if (get_current_screen()->id !== 'profile') { return; }
            
            	ob_end_flush();
            
            });
            */
        }
    }
예제 #5
0
 public function init()
 {
     parent::init();
     add_action('admin_init', array($this, 'register'));
 }