/** * General Settings Box */ private function group_profile() { /* * * GENERAL * * */ $this->args('descript', __('Show "Blog Posts" tab in user profiles', 'peepsoblogposts')); $this->set_field('blogposts_profile_enable', __('Enabled', 'peepsoblogposts'), 'yesno_switch'); /* * * CONTENT * * */ $this->set_field('blogposts_profile_content_separator', __('Post content', 'peepsoblogposts'), 'separator'); $this->args('int', TRUE); $this->args('default', 50); $this->args('descript', 'How many words of the post excerpt (or post content) to show. Leave empty to hide the content completely.'); // Once again the args will be included automatically. Note that args set before previous field are gone $this->set_field('blogposts_profile_content_length', __('Content length', 'peepsoblogposts'), 'text'); // DATE $this->args('descript', 'Put the date above/below post content, or disable it completely.'); $options = array('top' => __('above content', 'peepsoblogposts'), 'bottom' => __('below content', 'peepsoblogposts'), 'disable' => __('hidden', 'peepsoblogposts')); $this->args('options', $options); $this->set_field('blogposts_profile_date_position', __('Show date', 'peepsoblogposts'), 'select'); /* * * TWO COLUMNS * * */ $this->set_field('blogposts_profile_two_columns_separator', __('Two column layout', 'peepsoblogposts'), 'separator'); // TC ENABLE $this->set_field('blogposts_profile_two_column_enable', __('Two column layout', 'peepsoblogposts'), 'yesno_switch'); // TC HEIGHT $this->args('int', TRUE); $this->args('default', 350); $this->args('descript', ''); $this->set_field('blogposts_profile_two_column_height', __('Box height (px)', 'peepsoblogposts'), 'text'); // TC OVERFLOW HIDDEN $this->args('descript', ''); $this->args('default', 1); $this->args('descript', __('Recommended - maintains the layout in case of content exceeding size of the box')); $this->set_field('blogposts_profile_two_column_enable_overflow_hide', __('Clip long content', 'peepsoblogposts'), 'yesno_switch'); /* * * FEATURED IMAGES * * */ $this->set_field('blogposts_profile_featured_images_separator', __('Featured images', 'peepsoblogposts'), 'separator'); // FI ENABLE #$this->args('descript', __('Will display Featured Images if available','peepsoblogposts')); $this->set_field('blogposts_profile_featured_image_enable', __('Featured images', 'peepsoblogposts'), 'yesno_switch'); // FI POSITION $this->args('descript', ''); $options = array('top' => __('top', 'peepsoblogposts'), 'left' => __('left', 'peepsoblogposts'), 'right' => __('right', 'peepsoblogposts')); $this->args('options', $options); $this->set_field('blogposts_profile_featured_image_position', __('Position', 'peepsoblogposts'), 'select'); // FI HEIGTH $this->args('int', TRUE); $this->args('default', 150); $this->args('descript', __('The image will be a square if not placed on top.')); $this->set_field('blogposts_profile_featured_image_height', __('Height (px)', 'peepsoblogposts'), 'text'); // FI HALIGN $options = array('center' => __('center', 'peepsoblogposts'), 'left' => __('left', 'peepsoblogposts'), 'right' => __('right', 'peepsoblogposts')); $this->args('options', $options); $this->args('descript', 'How to align the image if it\'s wider than the box.'); $this->set_field('blogposts_profile_featured_image_align', __('Horizontal align', 'peepsoblogposts'), 'select'); // FI VALIGN $options = array('center' => __('center', 'peepsoblogposts'), 'top' => __('top', 'peepsoblogposts'), 'bottom' => __('bottom', 'peepsoblogposts')); $this->args('options', $options); $this->args('descript', 'How to align the image if it\'s taller than the box.'); $this->set_field('blogposts_profile_featured_image_align_vertical', __('Vertical align', 'peepsoblogposts'), 'select'); $this->args('descript', __('Will display an empty "placeholder" box if an image is not found. Recommended to maintain the layout in case of missing images.')); $this->set_field('blogposts_profile_featured_image_enable_if_empty', __('Placeholder', 'peepsoblogposts'), 'yesno_switch'); /* * * ADVANCED * * */ $this->set_field('blogposts_profile_template_overrides_separator', __('Advanced', 'peepsoblogposts'), 'separator'); // ADV TEMPLATE OVERRIDES $this->set_field('blogposts_profile_template_overrides', __('Use template overrides', 'peepsoblogposts'), 'yesno_switch'); $path = PeepSo::get_peepso_dir() . 'peepso-blogposts/templates/blogposts/'; $path_wide = $path . 'blogpost_wide.php'; $path_half = $path . 'blogpost_half.php'; $this->set_field('blogposts_profile_template_overrides_description', sprintf(__("\nYou can now create your own template files.<br/>\nPlease remember, that you are doing this at <b>your own resposibility</b> and that some features and options might stop working.<br>\nThe original files can be found in the \"templates\" directory of this plugin.\n<br><br>\n\nYou have to create the files in these exact locations:<br/><pre>Full width (single column view):\n%s\n\nHalf width (two column view):\n%s</pre>", 'peepsoblogposts'), $path_wide, $path_half), 'message'); /* * * GROUP * * */ $this->set_group('blogposts_general', __('Profiles Integration', 'peepsoblogposts')); }
/** * register hooks * * @return void */ public function init() { // Register classes and templates with PeepSo Core PeepSo::add_autoload_directory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR); if (1 == PeepSo::get_option('blogposts_profile_template_overrides', 0)) { PeepSoTemplate::add_template_directory(PeepSo::get_peepso_dir() . 'peepso-blogposts'); } PeepSoTemplate::add_template_directory(plugin_dir_path(__FILE__)); if (is_admin()) { add_action('admin_init', array(&$this, 'check_peepso')); // Add PeepSo Config tab add_filter('peepso_admin_config_tabs', array(&$this, 'admin_config_tabs')); } else { // Enqueue frontend JS & CSS add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); // Activity Stream item - User X "wrote a Z" text add_filter('peepso_activity_stream_action', array(&$this, 'activity_stream_action'), 10, 2); // Activity Item parser - include the embed add_filter('the_content', array(&$this, 'the_content'), 1, 2); // "Blog Posts" profile section if (PeepSo::get_option('blogposts_profile_enable', 0)) { // "User Profile" PeepSo Core widget add_filter('peepso_widget_me_links', array(&$this, 'peepso_widget_me_links')); // Profile segment menu item add_filter('peepso_profile_segment_menu_links', array(&$this, 'peepso_profile_segment_menu_links')); // Profile segment renderer add_action('peepso_profile_segment_blogposts', array(&$this, 'peepso_profile_segment_blogposts')); // Profile segment page title add_filter('peepso_page_title_profile_segment', array(&$this, 'peepso_page_title_profile_segment')); // @todo what is this add_filter('peepso_rewrite_profile_pages', array(&$this, 'peepso_rewrite_profile_pages')); } } // Register actions for each post type $post_types = PeepSoBlogPosts::get_post_types(); foreach ($post_types as $post_type) { add_action('publish_' . $post_type, array(&$this, 'publish_post'), 1, 2); } }