Ejemplo n.º 1
0
 public function restrict_entity_by_attributes()
 {
     global $typenow, $wp_query, $rtbiz_rt_attributes;
     $post_types = array(rtbiz_get_contact_post_type(), rtbiz_get_company_post_type());
     if (in_array($typenow, $post_types)) {
         $rtbiz_attributes_model = new RT_Attributes_Model();
         $rtbiz_attributes_relationship_model = new RT_Attributes_Relationship_Model();
         $relations = $rtbiz_attributes_relationship_model->get_relations_by_post_type($typenow);
         foreach ($relations as $r) {
             $attr = $rtbiz_attributes_model->get_attribute($r->attr_id);
             if ('taxonomy' == $attr->attribute_store_as) {
                 $tax = get_taxonomy($rtbiz_rt_attributes->get_taxonomy_name($attr->attribute_name));
                 if (!empty($tax)) {
                     $args = array('show_option_all' => __("Show All {$tax->label}"), 'taxonomy' => $rtbiz_rt_attributes->get_taxonomy_name($attr->attribute_name), 'name' => $rtbiz_rt_attributes->get_taxonomy_name($attr->attribute_name), 'orderby' => 'name', 'hierarchical' => true, 'depth' => 3, 'show_count' => false, 'hide_empty' => true);
                     if (isset($wp_query->query[$rtbiz_rt_attributes->get_taxonomy_name($attr->attribute_name)])) {
                         $args['selected'] = $wp_query->query[$rtbiz_rt_attributes->get_taxonomy_name($attr->attribute_name)];
                     }
                     wp_dropdown_categories($args);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 function test_constructor()
 {
     $this->assertTrue(post_type_exists(rtbiz_get_company_post_type()), 'Something is wrong in rt_account check class post type not exist');
 }
Ejemplo n.º 3
0
        public function rtbiz_welcome_panel()
        {
            $admin_cap = rtbiz_get_access_role_cap(RTBIZ_TEXT_DOMAIN, 'admin');
            $editor_cap = rtbiz_get_access_role_cap(RTBIZ_TEXT_DOMAIN, 'editor');
            $welcome_label = __('rtBiz');
            $contact_labels = rtbiz_get_contact_labels();
            $company_labels = rtbiz_get_company_labels();
            //$contact_group_labels = rtbiz_get_contact_group_labels();
            ?>
			<div class="welcome-panel-content">
				<h3><?php 
            _e('Welcome to ' . $welcome_label);
            ?>
</h3>

				<p class="about-description"><?php 
            _e('We&#8217;ve assembled some links to get you started:');
            ?>
</p>

				<div class="welcome-panel-column-container">
					<div class="welcome-panel-column">
						<?php 
            if (current_user_can($editor_cap)) {
                ?>
							<h4><?php 
                _e('Get Started');
                ?>
</h4>
							<a id="rtbiz-customize-biz" class="button button-primary button-hero"
							   href="<?php 
                echo admin_url('admin.php?page=' . Rtbiz_Setting::$page_slug);
                ?>
"><?php 
                echo $welcome_label . ' ' . __('Settings');
                ?>
</a>
						<?php 
            }
            ?>
						<?php 
            do_action('rtbiz_welcome_panel_addon_link');
            ?>
					</div>
					<div class="welcome-panel-column">
						<h4><?php 
            _e('Next Steps');
            ?>
</h4>
						<ul><?php 
            if (current_user_can($editor_cap)) {
                $rtbiz_setting_url = admin_url('admin.php?page=rt-biz-settings');
                echo '<li>';
                echo '<a class="welcome-icon welcome-admin-users" href="' . $rtbiz_setting_url . '" style="display: inline-block;" >' . __('Import') . ' ' . strtolower($contact_labels['name']) . '</a>';
                echo '</li>';
            }
            if (current_user_can($editor_cap)) {
                ?>
								<li><?php 
                printf('<a href="%s" class="welcome-icon welcome-universal-access-alt">' . __('Add new Team & assign them to') . ' ' . strtolower($contact_labels['singular_name']) . '</a>', admin_url('edit-tags.php?taxonomy=' . Rtbiz_Teams::$slug . '&post_type=' . rtbiz_get_contact_post_type()));
                ?>
</li>
							<?php 
            }
            if (current_user_can($admin_cap)) {
                ?>
								<li><?php 
                printf('<a href="%s" class="welcome-icon welcome-lock">' . __('Define your Access Control for') . ' ' . $welcome_label . '</a>', admin_url('admin.php?page=' . Rtbiz_Access_Control::$page_slug));
                ?>
</li>
							<?php 
            }
            ?>
						</ul>
					</div>

					<div class="welcome-panel-column welcome-panel-last">
						<h4><?php 
            _e('Quick Actions');
            ?>
</h4>
						<ul>
							<?php 
            if (current_user_can($editor_cap)) {
                ?>
								<li><?php 
                printf('<a id="rtiz-add-contact" href="%s" class="welcome-icon welcome-admin-users">' . __('Add new') . ' ' . $contact_labels['singular_name'] . '</a>', admin_url('post-new.php?post_type=' . rtbiz_get_contact_post_type()));
                ?>
</li>
								<!--<li><?php 
                /*printf( '<a href="%s" class="welcome-icon welcome-groups">' . __( 'Setup' ) . ' ' . $contact_group_labels['name'] . '</a>', admin_url( 'edit-tags.php?taxonomy=' . Rtbiz_Contact::$user_category_taxonomy . '&post_type=' . rtbiz_get_contact_post_type() ) ); */
                ?>
</li>-->
								<li><?php 
                printf('<a href="%s" class="welcome-icon welcome-admin-home">' . __('Add new') . ' ' . $company_labels['singular_name'] . '</a>', admin_url('post-new.php?post_type=' . rtbiz_get_company_post_type()));
                ?>
</li>
								<li><?php 
                printf('<a href="%s" class="welcome-icon welcome-networking">' . __('Setup Attributes') . '</a>', admin_url('admin.php?page=' . Rtbiz_Attributes::$page_slug));
                ?>
</li>
							<?php 
            } else {
                ?>
								<li><?php 
                printf('<a href="%s" class="welcome-icon welcome-groups">' . __('View your') . ' ' . $contact_labels['name'] . '</a>', admin_url('edit.php?post_type=' . rtbiz_get_contact_post_type()));
                ?>
</li>
								<li><?php 
                printf('<a href="%s" class="welcome-icon welcome-admin-home">' . __('View your') . ' ' . $company_labels['name'] . '</a>', admin_url('edit.php?post_type=' . rtbiz_get_company_post_type()));
                ?>
</li>
							<?php 
            }
            ?>
							<li><?php 
            printf('<a href="%s" class="welcome-icon welcome-learn-more">' . __('Learn more about getting started') . '</a>', 'http://docs.rtcamp.com/rtbiz/');
            ?>
</li>
						</ul>
					</div>
				</div>
			</div> <?php 
        }
        public static function ui($post)
        {
            if (rtbiz_get_contact_post_type() == $post->post_type) {
                $meta_fields = rtbiz_get_contact_meta_fields();
            } elseif (rtbiz_get_company_post_type() == $post->post_type) {
                $meta_fields = rtbiz_get_company_meta_fields();
            }
            do_action('rtbiz_before_render_meta_fields', $meta_fields);
            if (empty($meta_fields)) {
                return false;
            }
            ?>
			<div id="rtbiz-additional-detail-meta-box"> <?php 
            $category = array_unique(wp_list_pluck($meta_fields, 'category'));
            $cathtml = array();
            foreach ($category as $key => $value) {
                $cathtml[$value]['title'] = '<div><h3 class="rtbiz-category-title">' . __($value) . __(' information:') . ' </h3> </div>';
            }
            $cathtml['other']['title'] = '<div><h3 class="rtbiz-category-title">' . __('Other information:') . '</h3></div>';
            $other_flag = false;
            $is_our_team_mate = false;
            $postid = $post;
            if (is_object($post)) {
                $postid = $post->ID;
            }
            $wp_user = rtbiz_get_wp_user_for_contact($postid);
            //get wp user
            $cap = rtbiz_get_access_role_cap(RTBIZ_TEXT_DOMAIN, 'author');
            if (!empty($wp_user[0])) {
                $is_our_team_mate = user_can($wp_user[0], $cap);
            }
            foreach ($meta_fields as $field) {
                ob_start();
                $field = apply_filters('rtbiz_entity_fields_loop_single_field', $field);
                if (!$is_our_team_mate) {
                    if (isset($field['hide_for_client']) && $field['hide_for_client']) {
                        continue;
                    }
                }
                if (isset($field['is_datepicker']) && $field['is_datepicker']) {
                    $values = Rtbiz_Entity::get_meta($post->ID, $field['key'], true);
                    ?>
						<script>
							jQuery(document).ready(function ($) {
								$(document).on('focus', ".datepicker", function () {
									$(this).datepicker({
										'dateFormat': 'dd/mm/yy',
										changeMonth: true,
										changeYear: true
									});
								});
							});
						</script>
						<p class="rtbiz-form-group"><?php 
                    if (isset($field['label'])) {
                        ?>
							<label for="<?php 
                        echo isset($field['id']) ? '' . $field['id'] . '' : '';
                        ?>
">
								<?php 
                        echo $field['label'];
                        ?>
								</label><?php 
                    }
                    ?>
							<input type="text" <?php 
                    echo isset($field['name']) ? 'name="' . $field['name'] . '"' : '';
                    echo isset($field['id']) ? 'id="' . $field['id'] . '"' : '';
                    ?>
							       value='<?php 
                    echo $values;
                    ?>
' <?php 
                    echo isset($field['class']) ? 'class="datepicker ' . $field['class'] . '"' : 'class="datepicker"';
                    ?>
 >
							<br/><span></span>
						</p> <?php 
                } else {
                    if (isset($field['is_multiple']) && $field['is_multiple']) {
                        $values = Rtbiz_Entity::get_meta($post->ID, $field['key']);
                        ?>
						<p class="rtbiz-form-group"><?php 
                        if (isset($field['label'])) {
                            ?>
							<label for="<?php 
                            echo isset($field['id']) ? '' . $field['id'] . '' : '';
                            ?>
">
								<?php 
                            echo $field['label'];
                            ?>
								</label><?php 
                        }
                        ?>
							<input <?php 
                        echo isset($field['type']) ? 'type="' . $field['type'] . '"' : '';
                        ?>
								<?php 
                        echo isset($field['name']) ? 'name="' . $field['name'] . '"' : '';
                        ?>
								<?php 
                        echo isset($field['class']) ? 'class="' . $field['class'] . '"' : '';
                        ?>
 >

							<button data-type='<?php 
                        echo $field['type'];
                        ?>
' type='button'
							        class='button button-primary add-multiple'> +
							</button>

							<br/><span></span><?php 
                        foreach ($values as $value) {
                            ?>
								<input <?php 
                            echo isset($field['type']) ? 'type="' . $field['type'] . '"' : '';
                            echo isset($field['name']) ? 'name="' . $field['name'] . '"' : '';
                            ?>
									value='<?php 
                            echo $value;
                            ?>
' <?php 
                            echo isset($field['class']) ? 'class="second-multiple-input ' . $field['class'] . '"' : 'class="second-multiple-input"';
                            ?>
 >
								<button type='button' class='button delete-multiple'> -</button><?php 
                        }
                        ?>
						</p> <?php 
                    } else {
                        if (isset($field['type']) && 'textarea' == $field['type']) {
                            $values = Rtbiz_Entity::get_meta($post->ID, $field['key'], true);
                            ?>
						<p class="rtbiz-form-group"><?php 
                            if (isset($field['label'])) {
                                ?>
								<label
									for="<?php 
                                echo isset($field['id']) ? '' . $field['id'] . '' : '';
                                ?>
"><?php 
                                echo $field['label'];
                                ?>
								</label> <?php 
                            }
                            ?>
							<textarea <?php 
                            echo isset($field['name']) ? 'name="' . $field['name'] . '"' : '';
                            echo isset($field['id']) ? 'id="' . $field['id'] . '"' : '';
                            echo isset($field['class']) ? 'class="' . $field['class'] . '"' : '';
                            ?>
 > <?php 
                            echo $values;
                            ?>
 </textarea>
							<br/><span></span>
						</p> <?php 
                        } else {
                            if (isset($field['type']) && 'user_group' == $field['type']) {
                                $user_id = Rtbiz_Entity::get_meta($post->ID, $field['key'], true);
                                if (empty($user_id)) {
                                    continue;
                                }
                                ?>
					<p class="rtbiz-form-group"><?php 
                                call_user_func($field['data_source'], new WP_User($user_id));
                                ?>
					</p><?php 
                            } else {
                                if (isset($field['type']) && 'checkbox' == $field['type']) {
                                    $values = Rtbiz_Entity::get_meta($post->ID, $field['key'], true);
                                    ?>
						<p class="rtbiz-form-group rtbiz-form-checkbox">
							<label for="<?php 
                                    echo isset($field['id']) ? '' . $field['id'] . '' : '';
                                    ?>
">
								<input value='yes' <?php 
                                    echo 'yes' == $values ? 'checked' : '';
                                    ?>
								       type='checkbox' <?php 
                                    echo isset($field['name']) ? 'name="' . $field['name'] . '"' : '';
                                    echo isset($field['id']) ? 'id="' . $field['id'] . '"' : '';
                                    echo isset($field['class']) ? 'class="' . $field['class'] . '"' : '';
                                    ?>
 /><?php 
                                    echo $field['text'];
                                    ?>
</label>
							<br/><span></span>
						</p> <?php 
                                } else {
                                    $values = Rtbiz_Entity::get_meta($post->ID, $field['key'], true);
                                    ?>
						<p class="rtbiz-form-group"><?php 
                                    if (isset($field['label'])) {
                                        ?>
								<label for="<?php 
                                        echo isset($field['id']) ? '' . $field['id'] . '' : '';
                                        ?>
"><?php 
                                        echo $field['label'];
                                        ?>
								</label><?php 
                                    }
                                    ?>

							<input <?php 
                                    echo isset($field['type']) ? 'type="' . $field['type'] . '"' : '';
                                    echo isset($field['name']) ? 'name="' . $field['name'] . '"' : '';
                                    echo isset($field['id']) ? 'id="' . $field['id'] . '"' : '';
                                    ?>
								value='<?php 
                                    echo $values;
                                    ?>
' <?php 
                                    echo isset($field['class']) ? 'class="' . $field['class'] . '"' : '';
                                    ?>
 >
							<br/><span></span>
						</p> <?php 
                                }
                            }
                        }
                    }
                }
                $tmphtml = ob_get_clean();
                if (!isset($cathtml[$field['category']]['fields'])) {
                    $cathtml[$field['category']]['fields'] = '';
                }
                if (isset($field['category'])) {
                    $cathtml[$field['category']]['fields'] .= $tmphtml;
                } else {
                    $cathtml['other']['fields'] .= $tmphtml;
                    $other_flag = true;
                }
            }
            $printimpload = array();
            if (isset($cathtml['Contact'])) {
                $printimpload[] = $cathtml['Contact'];
                unset($cathtml['Contact']);
            }
            if (isset($cathtml['Social'])) {
                $printimpload[] = $cathtml['Social'];
                unset($cathtml['Social']);
            }
            if (isset($cathtml['HR'])) {
                if ($is_our_team_mate) {
                    $printimpload[] = $cathtml['HR'];
                }
                unset($cathtml['HR']);
            }
            foreach ($cathtml as $key => $value) {
                if ('other' == $key) {
                    if (true == $other_flag) {
                        $printimpload[] = $value;
                    }
                } else {
                    $printimpload[] = $value;
                }
            }
            $filter = function ($category) {
                return $category['title'] . '<div class="rtbiz-category-group">' . $category['fields'] . '</div>';
            };
            $printimpload = array_map($filter, $printimpload);
            echo implode('<div class="add-gap-div"><hr></div>', $printimpload);
            ?>

			</div> <?php 
            do_action('rtbiz_after_render_meta_fields', $post, $post->post_type);
            wp_nonce_field('rtbiz_additional_details_metabox', 'rtbiz_additional_details_metabox_nonce');
            if (rtbiz_get_contact_post_type() == $post->post_type) {
                /*  @var $rtbiz_contact Rtbiz_Contact */
                global $rtbiz_contact;
                $rtbiz_contact->print_metabox_js($post);
            } elseif (rtbiz_get_company_post_type() == $post->post_type) {
                /*  @var $rtbiz_company Rtbiz_Company */
                global $rtbiz_company;
                $rtbiz_company->print_metabox_js($post);
            }
            do_action('print_metabox_js', $post, $post->post_type);
        }
Ejemplo n.º 5
0
 public function preprocess_comment_handler($commentdata)
 {
     // Contact and company comments needed on from end in furture need to remove else condition.
     if (is_admin()) {
         if (function_exists('get_current_screen')) {
             $screen = get_current_screen();
             if (isset($screen->post_type) && (rtbiz_get_contact_post_type() != $screen->post_type && rtbiz_get_company_post_type() != $screen->post_type) && $screen->id != Rtbiz_Dashboard::$page_slug) {
                 $types = isset($commentdata->query_vars['type__not_in']) ? $commentdata->query_vars['type__not_in'] : array();
                 if (!is_array($types)) {
                     $types = array($types);
                 }
                 $types[] = 'rt_bot';
                 $commentdata->query_vars['type__not_in'] = $types;
             }
         }
     } else {
         $types = isset($commentdata->query_vars['type__not_in']) ? $commentdata->query_vars['type__not_in'] : array();
         if (!is_array($types)) {
             $types = array($types);
         }
         $types[] = 'rt_bot';
         $commentdata->query_vars['type__not_in'] = $types;
     }
     return $commentdata;
 }
Ejemplo n.º 6
0
 /**
  * Register the JavaScript for the admin area.
  *
  * @since    1.0.0
  */
 public function enqueue_scripts()
 {
     /**
      * This function is provided for demonstration purposes only.
      *
      * An instance of this class should be passed to the run() function
      * defined in Plugin_Name_Loader as all of the hooks are defined
      * in that particular class.
      *
      * The Plugin_Name_Loader will then create the relationship
      * between the defined hooks and the functions defined in this
      * class.
      */
     global $post;
     // Taxonomy menu hack for rtBiz
     if (isset($_REQUEST['taxonomy']) && isset($_REQUEST['post_type']) && in_array($_REQUEST['post_type'], array(rtbiz_get_contact_post_type(), rtbiz_get_company_post_type()))) {
         wp_localize_script(RTBIZ_TEXT_DOMAIN . 'admin-js', 'rtbiz_dashboard_screen', Rtbiz_Dashboard::$page_slug);
         wp_localize_script(RTBIZ_TEXT_DOMAIN . 'admin-js', 'rtbiz_menu_url', admin_url('edit-tags.php?taxonomy=' . $_REQUEST['taxonomy'] . '&post_type=' . $_REQUEST['post_type']));
     }
     wp_enqueue_script('jquery-ui-autocomplete', '', array('jquery-ui-widget', 'jquery-ui-position'), '1.9.2', true);
     wp_enqueue_script(RTBIZ_TEXT_DOMAIN . 'admin-js', RTBIZ_URL . 'admin/js/admin.js', array('jquery'), RTBIZ_VERSION, true);
     wp_localize_script(RTBIZ_TEXT_DOMAIN . 'admin-js', 'rtbiz_ajax_url_admin', admin_url('admin-ajax.php'));
 }