Example #1
0
 /**
  * Plugin Activation
  *
  */
 public function activate()
 {
     if (!class_exists('\\WP_CRM_F')) {
         include_once ud_get_wp_crm()->path("lib/class_functions.php", 'dir');
     }
     \WP_CRM_F::maybe_install_tables();
     \WP_CRM_F::manual_activation('auto_redirect=false&update_caps=true');
 }
Example #2
0
<?php

/**
 * Localization.
 * Fixes localization for some dynamic values.
 * Can be used for javascript localization
 *
 * @since 0.36.0
 * @author peshkov@UD
 * @package WP-CRM
 */
$l10n = array('actions' => __('Actions', ud_get_wp_crm()->domain), 'user_activity_history' => __('User Activity History', ud_get_wp_crm()->domain), 'primary_information' => __('Primary Information', ud_get_wp_crm()->domain), 'special_actions' => __('Special Actions', ud_get_wp_crm()->domain));
Example #3
0
 /**
  * Send notification on new_user_registration's ( new user is registered ) event
  *
  * @author peshkov@UD
  * @since 0.35.2
  */
 static function maybe_send_user_register_notification($user_id)
 {
     $action = 'new_user_registration';
     if (!is_callable('WP_CRM_N', 'get_trigger_action_notification')) {
         include_once ud_get_wp_crm()->path("lib/class_notification.php", 'dir');
     }
     $notifications = WP_CRM_N::get_trigger_action_notification($action);
     if (!empty($notifications)) {
         $userdata = get_userdata($user_id);
         if (!empty($userdata)) {
             wp_crm_send_notification($action, array('user_id' => $userdata->ID, 'user_login' => $userdata->user_login, 'user_email' => $userdata->user_email, 'user_url' => $userdata->user_url, 'display_name' => $userdata->display_name));
         }
     }
     return $user_id;
 }
        <input id="wp_crm_enable_developer_mode" value="true" type="checkbox" <?php 
checked(!empty($wp_crm['configuration']['developer_mode']) ? $wp_crm['configuration']['developer_mode'] : false, 'true');
?>
 name="wp_crm[configuration][developer_mode]" />
        <label for="wp_crm_enable_developer_mode"><?php 
_e("Enable developer mode and start displaying additional information in the console log.", ud_get_wp_crm()->domain);
?>
</label>
      </div>

      <?php 
do_action('wp_crm_settings_help_tab');
?>
    </div>
  </div>

</div>


<br class="cb" />

<p class="wp_crm_save_changes_row">
<input type="submit" value="<?php 
_e('Save Changes', ud_get_wp_crm()->domain);
?>
" class="button-primary" name="Submit">
 </p>


</form>
</div>
if (!empty($_REQUEST['message']) && $_REQUEST['message'] == 'created') {
    WP_CRM_F::add_message(__('Profile created.', ud_get_wp_crm()->domain));
} elseif (!empty($_REQUEST['message']) && $_REQUEST['message'] == 'updated') {
    WP_CRM_F::add_message(__('Profile updated.', ud_get_wp_crm()->domain));
}
/** Set GET param redirect_to. After user saving server will redirect to the current screen (redirect_to is current_screen ID). */
$redirect_to = !empty($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : "";
if ($wp_crm_user) {
    $user_id = $_REQUEST['user_id'];
    $object = $wp_crm_user;
    $title = WP_CRM_F::get_primary_display_value($object);
} else {
    $object = array();
    $object['new'] = true;
    $object['user_role']['default'][0] = get_option('default_role');
    $title = __('Add New Person', ud_get_wp_crm()->domain);
}
$wp_crm_js = array('user_id' => isset($user_id) && is_numeric($user_id) ? $user_id : false, 'hidden_attributes' => !empty($wp_crm['hidden_attributes']) ? $wp_crm['hidden_attributes'] : array());
if (!empty($wp_crm['configuration']['standardize_display_name']) && $wp_crm['configuration']['standardize_display_name'] == 'true' && !empty($wp_crm['configuration']['display_name_rule'])) {
    $wp_crm_js['standardize_display_name'] = true;
    $wp_crm_js['display_name_rule'] = $wp_crm['configuration']['display_name_rule'];
}
if (is_array($wp_crm_js)) {
    echo '<script type="text/javascript">var wp_crm = jQuery.parseJSON(' . json_encode(json_encode($wp_crm_js)) . '); </script>';
}
?>
<div class="wp_crm_profile_wrapper wrap">
  <div class="wp_crm_ajax_result"></div>
  <h2 class="wp_crm_page_title"><?php 
echo $title;
?>
Example #6
0
    /**
     * Sidebar metabox for administrative user actions
     *
     *
     * @todo Fix delete link to be handled internally and not depend on built-in user management
     * @since 0.01
     *
     */
    static function special_actions($object)
    {
        global $current_user, $wp_filter, $user_id, $_wp_admin_css_colors;
        $current_user_id = $current_user->ID;
        $user_id = !empty($object['ID']['default'][0]) ? $object['ID']['default'][0] : '';
        $profileuser = get_user_to_edit($user_id);
        if ($user_id == $current_user_id) {
            $own_profile = true;
        }
        ?>
    <div id="minor-publishing">
      <ul class="wp_crm_advanced_user_actions_wrapper">
        <li class="wp_crm_advanced_user_actions">
          <div class="wp_crm_toggle_advanced_user_actions wp_crm_link"><?php 
        _e('Toggle Settings', ud_get_wp_crm()->domain);
        ?>
</div>
          <div class="wp_crm_advanced_user_actions wp-tab-panel">
            <?php 
        if (current_user_can('edit_users')) {
            ?>
            <?php 
            if (current_user_can('WP-CRM: Change Passwords')) {
                ?>
              <?php 
                _e('Set Password:'******'Type in new password twice to change.', ud_get_wp_crm()->domain);
                ?>
</span>
                </li>
                <li>
                  <input type="password" autocomplete="off" value="" size="16" class="wp_crm_user_password" id="wp_crm_password_2" />
                  <span class="description"><?php 
                _e('Type your new password again.', ud_get_wp_crm()->domain);
                ?>
</span>
                </li>
              </ul>
              <?php 
            }
            ?>
              <?php 
            _e('Admin Options:', ud_get_wp_crm()->domain);
            ?>
              <ul>
                <?php 
            if (current_user_can('edit_users')) {
                ?>
                  <li class="wp_crm_edit_roles">
                    <label for="wp_crm_role"><?php 
                _e('Capability Role:', ud_get_wp_crm()->domain);
                ?>
</label>
                    <select id="wp_crm_role" <?php 
                echo !empty($own_profile) ? ' disabled="true" ' : '';
                ?>
 name="wp_crm[user_data][role][<?php 
                echo rand(1000, 9999);
                ?>
][value]">
                      <option value=""></option>
                  <?php 
                wp_dropdown_roles(!empty($object['role']['default'][0]) ? $object['role']['default'][0] : '');
                ?>
                    </select>
                  </li>
                <?php 
            }
            ?>
                <li class="wp_crm_capability_bar">
                  <input name="show_admin_bar_front" type="hidden" value="false"  />
                  <input name="show_admin_bar_front" type="checkbox" id="show_admin_bar_front" value="true" <?php 
            checked(_get_admin_bar_pref('front', !empty($profileuser->ID) ? $profileuser->ID : ''));
            ?>
 />
                  <label for="show_admin_bar_front"><?php 
            _e('Show Admin Bar when viewing site.', ud_get_wp_crm()->domain);
            ?>
 </label>
                </li>
              </ul>
            <?php 
        }
        ?>
            <?php 
        if (count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') && current_user_can('WP-CRM: Change Color Scheme')) {
            ?>
            <?php 
            _e('Color Scheme:', ud_get_wp_crm()->domain);
            do_action('admin_color_scheme_picker');
            ?>
            <?php 
        }
        ?>
            </div>
          </li>
        </ul>
        <?php 
        if (!empty($wp_filter['show_user_profile']) && count($wp_filter['show_user_profile']) || !empty($wp_filter['profile_personal_options']) && count($wp_filter['profile_personal_options'])) {
            ?>
          <div class="wp_crm_user_api_actions">
        <?php 
            add_filter('wpi_user_information', array('WP_CRM_F', 'wpi_user_information'));
            if (!empty($own_profile)) {
                do_action('show_user_profile', $profileuser);
            } else {
                do_action('edit_user_profile', $profileuser);
            }
            ?>
          </div>
        <?php 
        }
        ?>
        <?php 
        if (current_user_can('edit_users')) {
            do_action('wp_crm_metabox_special_actions');
        }
        ?>
        </div>

        <div class="major-publishing-actions">
          <div id="publishing-action">
            <input type="hidden" value="Publish" id="original_publish" name="original_publish" />
            <?php 
        if (current_user_can('edit_users') || current_user_can('add_users') && $object['new']) {
            ?>
            <input type="submit" accesskey="p" tabindex="5" value="<?php 
            echo !empty($object['new']) ? __('Save', ud_get_wp_crm()->domain) : __('Update', ud_get_wp_crm()->domain);
            ?>
" class="button-primary" id="publish" name="publish" />
              <?php 
        } else {
            ?>
                <input type="submit" accesskey="p" tabindex="5" value="<?php 
            echo !empty($object['new']) ? __('Save', ud_get_wp_crm()->domain) : __('Update', ud_get_wp_crm()->domain);
            ?>
" class="button-primary" id="publish" name="publish" disabled="true">
              <?php 
        }
        ?>
          </div>
          <div class="clear"></div>
        </div>

        <div class="wp_crm_user_actions">
          <ul class="wp_crm_action_list">
            <?php 
        do_action('wp_crm_single_user_actions', $object);
        ?>
            <?php 
        if ((current_user_can('remove_users') || current_user_can('delete_users')) && (empty($object['new']) && $user_id != $current_user->ID)) {
            ?>
              <li><a href="<?php 
            echo wp_nonce_url("admin.php?wp_crm_action=delete_user&page=wp_crm&user_id={$user_id}", 'wp-crm-delete-user-' . $user_id);
            ?>
" class="submitdelete deletion button"><?php 
            _e('Delete', ud_get_wp_crm()->domain);
            ?>
</a></li>
            <?php 
        }
        ?>
          </ul>
        </div>
    <?php 
    }
}
?>
  </tbody>
  </tbody>
  <tfoot>
    <tr>
      <th class="user"><?php 
_e('User', ud_get_wp_crm()->domain);
?>
</th>
      <th class="activity"><?php 
_e('Activity', ud_get_wp_crm()->domain);
?>
</th>
      <th class="location"><?php 
_e('Location', ud_get_wp_crm()->domain);
?>
</th>
      <th class="detail"><?php 
_e('ISP', ud_get_wp_crm()->domain);
?>
</th>
      <th class="time"><?php 
_e('Time', ud_get_wp_crm()->domain);
?>
</th>
    </tr>  
  </tfoot>
</table>

</div>
Example #8
0
 /**
  * 
  * @param type $current
  * @return string
  */
 static function wp_crm_overview_columns($current)
 {
     $current['forum_participation']['title'] = __('Forum Participation', ud_get_wp_crm()->domain);
     $current['forum_participation']['overview_column'] = 'true';
     return $current;
 }
Example #9
0
 /**
  * Draws table rows for ajax call
  *
  *
  * @since 0.1
  *
  */
 static function ajax_table_rows()
 {
     include ud_get_wp_crm()->path('lib/class_user_list_table.php', 'dir');
     //** Get the paramters we care about */
     $sEcho = $_REQUEST['sEcho'];
     $per_page = $_REQUEST['iDisplayLength'];
     $iDisplayStart = $_REQUEST['iDisplayStart'];
     $iColumns = $_REQUEST['iColumns'];
     parse_str($_REQUEST['wp_crm_filter_vars'], $wp_crm_filter_vars);
     $wp_crm_message_search = !empty($wp_crm_filter_vars['wp_crm_message_search']) ? $wp_crm_filter_vars['wp_crm_message_search'] : '';
     //* Init table object */
     $wp_list_table = new WP_CMR_List_Table("current_screen=crm_page_wp_crm_contact_messages&table_scope=wp_crm_contact_messages&ajax=true&per_page={$per_page}&iDisplayStart={$iDisplayStart}&iColumns={$iColumns}");
     //** Load items into table class */
     $wp_list_table->all_items = class_contact_messages::get_messages($wp_crm_message_search);
     $wp_list_table->prepare_items();
     if ($wp_list_table->has_items()) {
         foreach ($wp_list_table->items as $count => $item) {
             $data[] = $wp_list_table->single_row($item);
         }
     } else {
         $data[] = $wp_list_table->no_items();
     }
     return json_encode(array('sEcho' => $sEcho, 'iTotalRecords' => count($wp_list_table->all_items), 'iTotalDisplayRecords' => count($wp_list_table->all_items), 'aaData' => $data));
 }
Example #10
0
 *
 * Do not modify arrays found in these files, use the filters to modify them in your functions.php file
 * Sets up default settings and loads a few actions.
 *
 * Copyright 2011 Usability Dynamics, Inc. <*****@*****.**>
 *
 * @link http://twincitiestech.com/plugins/
 * @version 0.1
 * @author Usability Dynamics, Inc. <*****@*****.**>
 * @package WP-CRM
 */
$wp_crm_db = get_option('wp_crm_settings');
global $wp_crm;
$wp_crm['version'] = '0.1';
$wp_crm['configuration'] = array('default_user_capability' => 'prospect', 'default_user_capability_permissions_base' => 'subscriber', 'create_individual_pages_for_crm_capabilities' => 'true');
$wp_crm['configuration']['mail'] = array('sender_name' => get_bloginfo(), 'send_email' => get_bloginfo('admin_email'));
$wp_crm['configuration']['input_types'] = array('text' => __('Single Line Text', ud_get_wp_crm()->domain), 'checkbox' => __("Checkbox", ud_get_wp_crm()->domain), 'textarea' => __("Textarea", ud_get_wp_crm()->domain), 'dropdown' => __("Dropdown", ud_get_wp_crm()->domain), 'password' => __("Password", ud_get_wp_crm()->domain), 'date' => __("Date Picker", ud_get_wp_crm()->domain));
/**
 * Permissions to be utilized through the plugin.
 * These are automatically added to admin in WPP_C::init();
 */
$wp_crm['capabilities'] = array('Manage Settings' => __('View and edit plugin settings.', ud_get_wp_crm()->domain), 'View Overview' => __('View individual prospects and the overview page.', ud_get_wp_crm()->domain), 'View Detailed Logs' => __('View detailed user activity logs.', ud_get_wp_crm()->domain), 'View Profiles' => __('View a user\'s profile.', ud_get_wp_crm()->domain), 'Add User Messages' => __('Add to correspondence thread on a user\'s profile.', ud_get_wp_crm()->domain), 'Send Group Message' => __('Send a group message to users.', ud_get_wp_crm()->domain), 'Perform Advanced Functions' => __('Perform advanced functions such as merging users.', ud_get_wp_crm()->domain), 'Change Passwords' => __('Change passwords of other users. This is only checked if the user can edit users in the first place.', ud_get_wp_crm()->domain), 'Change Color Scheme' => __('Change color scheme. This is only checked if the user can edit users in the first place.', ud_get_wp_crm()->domain));
/** 
 * Overwrite $wp_crm with database setting 
 */
if (!empty($wp_crm_db)) {
    if (!class_exists('CRM_UD_F')) {
        require_once ud_get_wp_crm()->path('lib/class_ud.php', 'dir');
    }
    $wp_crm = CRM_UD_F::array_merge_recursive_distinct($wp_crm, $wp_crm_db);
}
Example #11
0
 function get_bulk_actions()
 {
     $actions = array();
     if (is_multisite()) {
         if (current_user_can('remove_users')) {
             $actions['remove'] = __('Remove', ud_get_wp_crm()->domain);
         }
     } else {
         if (current_user_can('delete_users')) {
             $actions['delete'] = __('Delete', ud_get_wp_crm()->domain);
         }
     }
     return $actions;
 }
Example #12
0
 /**
  * WP-CRM Contextual Help
  *
  * @param type $args
  *
  * @author korotkov@UD
  */
 static function wp_crm_contextual_help($args = array())
 {
     $defaults = array('contextual_help' => array());
     extract(wp_parse_args($args, $defaults));
     //** If method exists add_help_tab in WP_Screen */
     if (is_callable(array('WP_Screen', 'add_help_tab'))) {
         //** Loop through help items and build tabs */
         foreach ((array) $contextual_help as $help_tab_title => $help) {
             //** Add tab with current info */
             get_current_screen()->add_help_tab(array('id' => sanitize_title($help_tab_title), 'title' => __($help_tab_title, ud_get_wp_crm()->domain), 'content' => implode("\n", (array) $contextual_help[$help_tab_title])));
         }
         if (is_callable(array('WP_Screen', 'set_help_sidebar'))) {
             //** Add help sidebar with More Links */
             get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:', ud_get_wp_crm()->domain) . '</strong></p>' . '<p><a href="https://usabilitydynamics.com/products/wp-crm/" target="_blank">' . __('WP-CRM Product Page', ud_get_wp_crm()->domain) . '</a></p>' . '<p><a href="https://usabilitydynamics.com/products/wp-crm/forum/" target="_blank">' . __('WP-CRM Forums', ud_get_wp_crm()->domain) . '</a></p>');
         }
     } else {
         //** If WP is out of date */
         global $current_screen;
         add_contextual_help($current_screen->id, '<p>' . __('Please upgrade Wordpress to the latest version for detailed help.', ud_get_wp_crm()->domain) . '</p><p>' . __('Or visit', ud_get_wp_crm()->domain) . ' <a href="https://usabilitydynamics.com/products/wp-crm/" target="_blank">' . __('WP-CRM Help Page', ud_get_wp_crm()->domain) . '</a> ' . __('on UsabilityDynamics.com', ud_get_wp_crm()->domain) . '</p>');
     }
 }
Example #13
0
 /**
  * 
  * @param type $current
  * @return string
  */
 static function wp_crm_overview_columns($current)
 {
     $current['wpi_sales']['title'] = __('Sales', ud_get_wp_crm()->domain);
     $current['wpi_sales']['overview_column'] = 'true';
     return $current;
 }
Example #14
0
<div class="wp_crm_overview_wrapper wrap">
<div class="wp_crm_ajax_result"></div>
    <?php 
screen_icon();
?>
    <h2><?php 
_e('CRM - All People', ud_get_wp_crm()->domain);
?>
 <?php 
if (current_user_can('WP-CRM: View Profiles') && (current_user_can('create_users') || current_user_can('add_users'))) {
    ?>
<a href="<?php 
    echo admin_url('admin.php?page=wp_crm_add_new');
    ?>
" class="button add-new-h2"><?php 
    _e('Add New', ud_get_wp_crm()->domain);
    ?>
</a><?php 
}
?>
</h2>
    <?php 
WP_CRM_F::print_messages();
?>

    <form id="wp-crm-filter" action="#" method="POST">
    <?php 
if (!CRM_UD_F::is_older_wp_version('3.4')) {
    ?>
    <div id="poststuff" class="crm-wp-v34">
      <div id="post-body" class="metabox-holder <?php 
Example #15
0
            if (!class_exists('\\UsabilityDynamics\\WPC\\WPC_Bootstrap')) {
                throw new Exception(__('Distributive is broken. Plugin loader is not available. Try to remove and upload plugin again.', 'wp-crm'));
            }
        } catch (Exception $e) {
            $_ud_wp_crm_error = $e->getMessage();
            return false;
        }
        return true;
    }
}
if (!function_exists('ud_my_wp_plugin_message')) {
    /**
     * Renders admin notes in case there are errors on plugin init
     *
     * @author Usability Dynamics, Inc.
     * @since 1.0.0
     */
    function ud_wp_crm_message()
    {
        global $_ud_wp_crm_error;
        if (!empty($_ud_wp_crm_error)) {
            $message = sprintf(__('<p><b>%s</b> can not be initialized. %s</p>', 'wp-crm'), 'WP-CRM', $_ud_wp_crm_error);
            echo '<div class="error fade" style="padding:11px;">' . $message . '</div>';
        }
    }
    add_action('admin_notices', 'ud_wp_crm_message');
}
if (ud_check_wp_crm()) {
    //** Initialize. */
    ud_get_wp_crm();
}
Example #16
0
 /**
  * Saves Buddypress profile data.
  *
  * @uses WP_CRM_Core::wp_crm_save_user_data()
  * @param array $data. Request (POST,GET)
  * @author peshkov@UD
  */
 static function bp_save_profile_data($data)
 {
     global $bp;
     if (empty($data['bp']) || empty($data['user_id'])) {
         return;
     }
     //* Set necessary variables */
     $user_id = $data['user_id'];
     $user_data = $data['wp_crm']['user_data'];
     $data = $data['bp'];
     $errors = false;
     $posted_field_ids = array();
     $is_required = array();
     //* Set xprofile full name from display_name */
     $display_name = WP_CRM_F::get_first_value($user_data['display_name']);
     if (!empty($display_name)) {
         $fullname_field_name = bp_xprofile_fullname_field_name();
         $fullname_field_id = xprofile_get_field_id_from_name($fullname_field_name);
         $data["field_{$fullname_field_id}"] = $display_name;
     }
     //* Get all posted field ids */
     foreach ($data as $name => $value) {
         $field_id = str_replace(array('field_', '_day', '_month', '_year'), '', $name);
         array_push($posted_field_ids, $field_id);
     }
     $posted_field_ids = array_unique($posted_field_ids);
     //* Validate the field */
     foreach ($posted_field_ids as $field_id) {
         if (!isset($data['field_' . $field_id])) {
             if (!empty($data['field_' . $field_id . '_day']) && !empty($data['field_' . $field_id . '_month']) && !empty($data['field_' . $field_id . '_year'])) {
                 /* Concatenate the values */
                 $date_value = $data['field_' . $field_id . '_day'] . ' ' . $data['field_' . $field_id . '_month'] . ' ' . $data['field_' . $field_id . '_year'];
                 /* Turn the concatenated value into a timestamp */
                 $data['field_' . $field_id] = date('Y-m-d H:i:s', strtotime($date_value));
             }
         }
         $is_required[$field_id] = xprofile_check_is_required_field($field_id);
         if ($is_required[$field_id] && empty($data['field_' . $field_id])) {
             $errors = true;
         }
     }
     //** There are errors */
     if ($errors) {
         WP_CRM_F::add_message(__('Please make sure you fill in all required Buddypress fields in this profile field group before saving.', ud_get_wp_crm()->domain), 'bad');
         //** No errors */
     } else {
         //** Now we've checked for required fields, lets save the values. */
         foreach ($posted_field_ids as $field_id) {
             //** Certain types of fields (checkboxes, multiselects) may come through empty. */
             //** Save them as an empty array so that they don't get overwritten by the default on the next edit. */
             if (empty($data['field_' . $field_id])) {
                 $value = array();
             } else {
                 $value = $data['field_' . $field_id];
             }
             if (!xprofile_set_field_data($field_id, $user_id, $value, $is_required[$field_id])) {
                 $errors = true;
             } else {
                 do_action('xprofile_profile_field_data_updated', $field_id, $value);
             }
         }
         //** Set the feedback message if we have error */
         if ($errors) {
             WP_CRM_F::add_message(__('There was a problem updating some of Buddypress profile information, please try again.', ud_get_wp_crm()->domain), 'bad');
         }
     }
 }
Example #17
0
      <h4><?php 
_e('Adding License Keys', ud_get_wp_crm()->domain);
?>
</h4>

      <p><?php 
_e('Click to activate plugin, you will see link to the Licenses admin screen. On the Licenses admin screen, you should see all your installed products, with an option to add your license key.', ud_get_wp_crm()->domain);
?>
</p>

      <p><?php 
_e('To add a license key:', ud_get_wp_crm()->domain);
?>
</p>

      <ul>
        <li><?php 
_e('copy the license key from your UD Account page or receipt email;', ud_get_wp_crm()->domain);
?>
</li>
        <li><?php 
_e('paste the license key into input field for your product;', ud_get_wp_crm()->domain);
?>
</li>
      </ul>

    </div>

  </div>

</div>
Example #18
0
 /**
  * 
  * @return string
  */
 function no_items()
 {
     //** DataTables expects a set number of columns */
     $result[0] = '';
     $result[1] = __('Nothing found.', ud_get_wp_crm()->domain);
     if (count($result) < $this->_args['iColumns']) {
         $add_columns = $this->_args['iColumns'] - count($result);
         //** Add some blank rows to not break json result array */
         $i = 1;
         while ($i <= $add_columns) {
             $result[] = '';
             $i++;
         }
     }
     return $result;
 }
Example #19
0
 /**
  * Convert a string to a url-like slug
  *
  * @since 1.4
  */
 static function slug_to_label($slug = false)
 {
     if (!$slug) {
         return '';
     }
     //** May be use custom label for slug */
     $label = apply_filters('crm::slug_to_label', $slug);
     if ($label !== $slug) {
         return $label;
     }
     //** Include the list of translations */
     //** and try to get value for current slug from this list. */
     $l10n = array();
     include ud_get_wp_crm()->path("l10n.php", 'dir');
     if (!empty($l10n[$slug])) {
         return $l10n[$slug];
     }
     $slug = str_replace("_", " ", $slug);
     $slug = ucwords($slug);
     return $slug;
 }
Example #20
0
    /**
     * Render groups list table
     * @global array $wp_crm
     * @author korotkov@ud
     */
    static function add_grouping_settings()
    {
        global $wp_crm;
        ob_start();
        ?>
    <tr>
      <th><?php 
        _e('Attributes Groups', ud_get_wp_crm()->domain);
        ?>
</th>
      <td>
        <table id="wp_crm_attribute_groups" class="ud_ui_dynamic_table widefat">
          <thead>
            <tr>
              <th class="wp_crm_name_col"><?php 
        _e('Group Name', ud_get_wp_crm()->domain);
        ?>
</th>
              <th class="wp_crm_metabox_col"><?php 
        _e('Metabox Title', ud_get_wp_crm()->domain);
        ?>
</th>
              <th class="wp_crm_delete_col"><?php 
        _e('Actions', ud_get_wp_crm()->domain);
        ?>
</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>
                <input readonly="readonly" type="text" value="<?php 
        _e('Primary Information', ud_get_wp_crm()->domain);
        ?>
" />
              </td>
              <td>
                <input readonly="readonly" type="text" value="<?php 
        _e('Primary Information', ud_get_wp_crm()->domain);
        ?>
" />
              </td>
              <td>
              </td>
            </tr>
    <?php 
        if (!empty($wp_crm['data_structure']['attribute_groups']) && is_array($wp_crm['data_structure']['attribute_groups'])) {
            foreach ($wp_crm['data_structure']['attribute_groups'] as $slug => $value) {
                ?>
                <tr class="wp_crm_dynamic_table_row" slug="<?php 
                echo $slug;
                ?>
"  new_row='false'>
                  <td>
                    <input class="slug_setter" type="text" name="wp_crm[data_structure][attribute_groups][<?php 
                echo $slug;
                ?>
][title]" value="<?php 
                echo $value['title'];
                ?>
" />
                  </td>
                  <td>
                    <input type="text" name="wp_crm[data_structure][attribute_groups][<?php 
                echo $slug;
                ?>
][metabox]" value="<?php 
                echo $value['metabox'];
                ?>
" />
                    <input style="display:none;" type="text" class="slug" readonly="readonly" value="<?php 
                echo $slug;
                ?>
" />
                  </td>
                  <td>
                    <span class="wp_crm_delete_row  button"><?php 
                _e('Delete', ud_get_wp_crm()->domain);
                ?>
</span>
                  </td>
                </tr>
        <?php 
            }
        } else {
            ?>
              <tr class="wp_crm_dynamic_table_row" slug="sample"  new_row='true'>
                <td>
                  <input class="slug_setter" type="text" name="wp_crm[data_structure][attribute_groups][sample][title]" value="Sample" />
                </td>
                <td>
                  <input type="text" name="wp_crm[data_structure][attribute_groups][sample][metabox]" value="Sample Attributes" />
                  <input style="display:none;" type="text" class="slug" readonly="readonly" value="sample" />
                </td>
                <td>
                  <span class="wp_crm_delete_row  button"><?php 
            _e('Delete', ud_get_wp_crm()->domain);
            ?>
</span>
                </td>
              </tr>
    <?php 
        }
        ?>
          </tbody>
          <tfoot>
            <tr>
              <td colspan="3">
                <input type="button" class="wp_crm_add_row button-secondary" value="<?php 
        _e('Add Row', ud_get_wp_crm()->domain);
        ?>
" />
              </td>
            </tr>
          </tfoot>
        </table>
      </td>
    </tr>
    <?php 
        $html = apply_filters('wp_crm_add_grouping_settings', ob_get_contents());
        ob_clean();
        echo $html;
    }