public function plugin_activation($is_core = FALSE) { $defaults = array('blogposts_activity_enable' => 0, 'blogposts_activity_privacy' => 10, 'blogposts_activity_type_post' => 1, 'blogposts_activity_type_post_text_default' => 'wrote a new post', 'blogposts_activity_type_page_text' => 'published a new page', 'blogposts_activity_type_attachment_text' => 'created a new attachment', 'blogposts_activity_type_revision_text' => 'created a new revision', 'blogposts_activity_type_nav_menu_item_text' => 'created a new menu item'); // Set some default settings $settings = PeepSoConfigSettings::get_instance(); foreach ($defaults as $key => $value) { if (in_array(PeepSo::get_option($key, NULL), array(NULL, ''))) { $settings->set_option($key, $value); } } parent::plugin_activation(); return TRUE; }
private function group_post_types() { $post_types = PeepSoBlogPosts::get_post_types(); $message = __('Enable the post types you want to be handled by this integration.', 'peepsoblogposts') . '<br/>' . __('Only post types presently registered are visible.', 'peepsoblogposts') . '<br/>' . __('You can override the <i>action text</i> for each post type with custom wording.', 'peepsoblogposts'); $this->set_field('post_types_message', $message, 'message'); foreach ($post_types as $post_type) { $key = 'blogposts_activity_type_' . $post_type; $key_text = $key . '_text'; $this->set_field($post_type . '_separator', $post_type, 'separator'); $this->set_field($key, 'Enable', 'yesno_switch'); $this->args('default', PeepSo::get_option('blogposts_activity_type_post_text_default')); $this->set_field($key_text, 'Action text', 'text'); } $this->set_group('blogposts_activity_post_types', __('Activity Stream Integration - Post types', 'peepsoblogposts')); }
/** * define the "action text" depending on post type eg "published a page" * * @param $action * @param $post * @return string */ public function activity_stream_action($action, $post) { if (self::MODULE_ID === intval($post->act_module_id)) { $action = PeepSo::get_option('blogposts_activity_type_post_text_default'); // @since 0.0.5 $content = strip_tags(get_post_field('post_content', $post, 'raw')); if ($target_post = json_decode($content)) { $key_text = 'blogposts_activity_type_' . $target_post->post_type . '_text'; $action = PeepSo::get_option($key_text, $action); } } return $action; }