Exemplo n.º 1
4
 /**
  * Set the notification email when sending an email.
  *
  * @since WP Job Manager - Contact Listing 1.0.0
  *
  * @return string The email to notify.
  */
 public function notification_email($components, $cf7, $three = null)
 {
     $submission = WPCF7_Submission::get_instance();
     $unit_tag = $submission->get_meta('unit_tag');
     if (!preg_match('/^wpcf7-f(\\d+)-p(\\d+)-o(\\d+)$/', $unit_tag, $matches)) {
         return $components;
     }
     $post_id = (int) $matches[2];
     $object = get_post($post_id);
     // Prevent issues when the form is not submitted via a listing/resume page
     if (!isset($this->forms[$object->post_type])) {
         return $components;
     }
     if (!array_search($cf7->id(), $this->forms[$object->post_type])) {
         return $components;
     }
     // Bail if this is the second mail
     if (isset($three) && 'mail_2' == $three->name()) {
         return $components;
     }
     $recipient = $object->_application ? $object->_application : $object->_candidate_email;
     //if we couldn't find the email by now, get it from the listing owner/author
     if (empty($recipient)) {
         //just get the email of the listing author
         $owner_ID = $object->post_author;
         //retrieve the owner user data to get the email
         $owner_info = get_userdata($owner_ID);
         if (false !== $owner_info) {
             $recipient = $owner_info->user_email;
         }
     }
     $components['recipient'] = $recipient;
     return $components;
 }
Exemplo n.º 2
1
 /**
  * 
  *  Woo User Menu
  */
 function user_menu()
 {
     $_Twoot_Woo = new Twoot_Woo();
     $url = $_Twoot_Woo->shop_urls();
     $user_data = get_userdata(get_current_user_id());
     $avatar = get_option('show_avatars') ? '<span class="avatar">' . get_avatar(get_current_user_id(), 20) . '</span>' : '';
     $tag = get_option('permalink_structure') == false ? '&' : '?';
     $html = '<nav id="woo-user-menu">';
     $html .= '<ul class="sf-menu clearfix">';
     if (is_user_logged_in()) {
         $html .= '<li class="my-account"><a href="' . $url['account_overview'] . '">' . $avatar . esc_attr__('Howdy, ', 'Twoot') . $user_data->display_name . '</a>';
         $html .= '<ul>';
         $html .= '<li class="account-change-pw"><a href="' . $url['account_change_pw'] . '">' . esc_attr__('Change Password', 'Twoot') . '</a></li>';
         $html .= '<li class="account-edit-adress"><a href="' . $url['account_edit_adress'] . '">' . esc_attr__('Edit Address', 'Twoot') . '</a></li>';
         $html .= '<li class="account-view-order"><a href="' . $url['account_view_order'] . '">' . esc_attr__('View Order', 'Twoot') . '</a></li>';
         $html .= '<li class="cart"><a href="' . $url['cart'] . '">' . esc_attr__('Shopping Cart', 'Twoot') . '</a></li>';
         $html .= '<li class="checkout"><a href="' . $url['checkout'] . '">' . esc_attr__('Checkout', 'Twoot') . '</a></li>';
         $html .= '</ul>';
         $html .= '</li>';
         $html .= '<li class="logout last"><a href="' . $url['logout'] . '">' . esc_attr__('Sign Out', 'Twoot') . '</a></li>';
     } else {
         if (get_option('users_can_register') && get_option('woocommerce_enable_myaccount_registration') == 'yes') {
             $html .= '<li class="register"><a href="' . $url['register'] . $tag . 'user_account=register">' . esc_attr__('Create Account', 'Twoot') . '</a></li>';
         }
         $html .= '<li class="login last"><a href="' . $url['account_overview'] . $tag . 'user_account=login">' . esc_attr__('Sign In', 'Twoot') . '</a></li>';
     }
     $html .= '</ul>';
     $html .= '</nav>';
     return $html;
 }
Exemplo n.º 3
1
 public function glossary_entries_get($project_path, $locale_slug, $translation_set_slug)
 {
     $project = GP::$project->by_path($project_path);
     $locale = GP_Locales::by_slug($locale_slug);
     if (!$project || !$locale) {
         return $this->die_with_404();
     }
     $translation_set = GP::$translation_set->by_project_id_slug_and_locale($project->id, $translation_set_slug, $locale_slug);
     if (!$translation_set) {
         return $this->die_with_404();
     }
     $glossary = GP::$glossary->by_set_or_parent_project($translation_set, $project);
     if (!$glossary) {
         return $this->die_with_404();
     }
     $glossary_entries = GP::$glossary_entry->by_glossary_id($glossary->id);
     foreach ($glossary_entries as $key => $entry) {
         $user = get_userdata($entry->last_edited_by);
         if ($user) {
             $glossary_entries[$key]->user_login = $user->user_login;
             $glossary_entries[$key]->user_display_name = $user->display_name;
         }
     }
     $can_edit = $this->can('approve', 'translation-set', $translation_set->id);
     $url = gp_url_join(gp_url_project_locale($project_path, $locale_slug, $translation_set_slug), array('glossary'));
     $this->tmpl('glossary-view', get_defined_vars());
 }
Exemplo n.º 4
0
 public function userstats($atts)
 {
     if (!is_user_logged_in()) {
         return;
     }
     extract($this->correct(wp_parse_args($atts, $this->stataway_user), $this->shortcodes['stataway_user']));
     global $wpdb;
     $userid = $user && is_numeric($user) ? $user : get_current_user_id();
     if (!get_userdata($userid)) {
         return false;
     }
     fileaway_utility::timezone();
     $now = date('Y-m-d H:i:s');
     switch ($scope) {
         case '24hrs':
             $begin = date('Y-m-d H:i:s', strtotime($now . ' - 24 hours'));
             break;
         case 'week':
             $begin = date('Y-m-d H:i:s', strtotime($now . ' - 1 week'));
             break;
         case 'twoweeks':
             $begin = date('Y-m-d H:i:s', strtotime($now . ' - 2 weeks'));
             break;
         case 'month':
             $begin = date('Y-m-d H:i:s', strtotime($now . ' - 30 days'));
             break;
         case 'year':
             $begin = date('Y-m-d H:i:s', strtotime($now . ' - 1 year'));
             break;
         case 'all':
             $begin = '1900-01-01 00:00:00';
             break;
         default:
             $begin = date('Y-m-d H:i:s', strtotime($now . ' - 1 week'));
     }
     $end = $now;
     $records = $wpdb->get_results($wpdb->prepare("SELECT file, timestamp FROM " . fileaway_stats::$db . " WHERE uid = %d AND timestamp >= %s AND timestamp <= %s ORDER BY timestamp DESC", $userid, $begin, $end), ARRAY_A);
     if (!$records || count($records) < 1) {
         $count = 0;
     } else {
         $count = count($records);
     }
     date_default_timezone_set('UTC');
     if ($output == 'total') {
         return '<span class="' . $class . '">' . $count . '</span>';
     }
     if ($count < 1) {
         return false;
     }
     $datestring = $this->op['daymonth'] == 'md' ? 'm/d/Y' : 'd/m/Y';
     $items = array();
     foreach ($records as $i => $record) {
         $items[$i] = '<li>' . fileaway_utility::basename($record['file']);
         if ($timestamp == 'yes') {
             $items[$i] .= ' <span style="display:block;" class="' . $class . 'timestamp">' . date($datestring . ' ' . get_option('time_format'), strtotime($record['timestamp'])) . '</span>';
         }
         $items[$i] .= '</li>';
     }
     return '<div class="' . $class . '"><' . $output . '>' . implode($items) . '</' . $output . '></div>';
 }
 /**
  * Get the Export Data.
  *
  * @access public
  * @since 1.5
  * @global object $wpdb Used to query the database using the WordPress database API.
  * @return array $data The data for the CSV file.
  */
 public function get_data()
 {
     global $wpdb;
     $data = array();
     $args = array('number' => 30, 'page' => $this->step, 'status' => $this->status);
     if (!empty($this->start) || !empty($this->end)) {
         $args['date_query'] = array(array('after' => date('Y-n-d 00:00:00', strtotime($this->start)), 'before' => date('Y-n-d 23:59:59', strtotime($this->end)), 'inclusive' => true));
     }
     //echo json_encode($args ); exit;
     $payments = give_get_payments($args);
     if ($payments) {
         foreach ($payments as $payment) {
             $payment_meta = give_get_payment_meta($payment->ID);
             $user_info = give_get_payment_meta_user_info($payment->ID);
             $total = give_get_payment_amount($payment->ID);
             $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email'];
             $products = '';
             $skus = '';
             if (is_numeric($user_id)) {
                 $user = get_userdata($user_id);
             } else {
                 $user = false;
             }
             $data[] = array('id' => $payment->ID, 'seq_id' => give_get_payment_number($payment->ID), 'email' => $payment_meta['email'], 'first' => $user_info['first_name'], 'last' => $user_info['last_name'], 'address1' => isset($user_info['address']['line1']) ? $user_info['address']['line1'] : '', 'address2' => isset($user_info['address']['line2']) ? $user_info['address']['line2'] : '', 'city' => isset($user_info['address']['city']) ? $user_info['address']['city'] : '', 'state' => isset($user_info['address']['state']) ? $user_info['address']['state'] : '', 'country' => isset($user_info['address']['country']) ? $user_info['address']['country'] : '', 'zip' => isset($user_info['address']['zip']) ? $user_info['address']['zip'] : '', 'form_id' => isset($payment_meta['form_id']) ? $payment_meta['form_id'] : '', 'form_name' => isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '', 'skus' => $skus, 'amount' => html_entity_decode(give_format_amount($total)), 'gateway' => give_get_gateway_admin_label(get_post_meta($payment->ID, '_give_payment_gateway', true)), 'trans_id' => give_get_payment_transaction_id($payment->ID), 'key' => $payment_meta['key'], 'date' => $payment->post_date, 'user' => $user ? $user->display_name : __('guest', 'give'), 'status' => give_get_payment_status($payment, true));
         }
         $data = apply_filters('give_export_get_data', $data);
         $data = apply_filters('give_export_get_data_' . $this->export_type, $data);
         return $data;
     }
     return false;
 }
Exemplo n.º 6
0
 /**
  * Create a simple donation payment.
  *
  * @since 1.0
  */
 public static function create_simple_payment()
 {
     global $give_options;
     // Enable a few options
     $give_options['enable_sequential'] = '1';
     $give_options['sequential_prefix'] = 'GIVE-';
     update_option('give_settings', $give_options);
     $simple_form = Give_Helper_Form::create_simple_form();
     $multilevel_form = Give_Helper_Form::create_multilevel_form();
     /** Generate some donations */
     $user = get_userdata(1);
     $user_info = array('id' => $user->ID, 'email' => $user->user_email, 'first_name' => $user->first_name, 'last_name' => $user->last_name);
     $total = 0;
     $simple_price = get_post_meta($simple_form->ID, 'give_price', true);
     $variable_prices = get_post_meta($multilevel_form->ID, 'give_variable_prices', true);
     $variable_item_price = $variable_prices[1]['amount'];
     // == $100
     $total += $variable_item_price + $simple_price;
     $purchase_data = array('price' => number_format((double) $total, 2), 'give_form_title' => 'Test Donation', 'give_form_id' => $simple_form->ID, 'date' => date('Y-m-d H:i:s', strtotime('-1 day')), 'purchase_key' => strtolower(md5(uniqid())), 'user_email' => $user_info['email'], 'user_info' => $user_info, 'currency' => 'USD', 'status' => 'pending');
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     $_SERVER['SERVER_NAME'] = 'give_virtual';
     $payment_id = give_insert_payment($purchase_data);
     $key = $purchase_data['purchase_key'];
     $transaction_id = 'FIR3SID3';
     give_set_payment_transaction_id($payment_id, $transaction_id);
     give_insert_payment_note($payment_id, sprintf(__('PayPal Transaction ID: %s', 'give'), $transaction_id));
     return $payment_id;
 }
function friends_notification_accepted_request($friendship_id, $initiator_id, $friend_id)
{
    global $bp;
    $friendship = new BP_Friends_Friendship($friendship_id, false, false);
    $friend_name = bp_core_get_user_displayname($friend_id);
    if ('no' == bp_get_user_meta((int) $initiator_id, 'notification_friends_friendship_accepted', true)) {
        return false;
    }
    $ud = get_userdata($initiator_id);
    $friend_link = bp_core_get_user_domain($friend_id);
    $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
    $settings_link = bp_core_get_user_domain($initiator_id) . $settings_slug . '/notifications';
    // Set up and send the message
    $to = $ud->user_email;
    $sitename = nxt_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
    $subject = '[' . $sitename . '] ' . sprintf(__('%s accepted your friendship request', 'buddypress'), $friend_name);
    $message = sprintf(__('%1$s accepted your friend request.

To view %2$s\'s profile: %3$s

---------------------
', 'buddypress'), $friend_name, $friend_name, $friend_link);
    $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
    /* Send the message */
    $to = apply_filters('friends_notification_accepted_request_to', $to);
    $subject = apply_filters('friends_notification_accepted_request_subject', $subject, $friend_name);
    $message = apply_filters('friends_notification_accepted_request_message', $message, $friend_name, $friend_link, $settings_link);
    nxt_mail($to, $subject, $message);
    do_action('bp_friends_sent_accepted_email', $initiator_id, $subject, $message, $friendship_id, $friend_id);
}
    function column_default($item, $column_name)
    {
        switch ($column_name) {
            case 'author':
                $user_info = get_userdata($item->post_author);
                if (!$user_info) {
                    echo '<strong>Anonymous</strong>';
                } else {
                    echo '<strong>' . get_avatar($item->post_author, $size = '32') . ' ' . $user_info->display_name . '</strong>';
                }
                break;
            case 'detail':
                global $post;
                setup_postdata($item);
                ?>
        		<div class="submitted-on"><?php 
                _e('Answered on ', 'dwqa');
                ?>
<a href="<?php 
                echo get_permalink($item->ID);
                ?>
"><?php 
                echo $item->post_date;
                ?>
</a></div>
        		<?php 
                the_excerpt();
                ?>
        		<?php 
                break;
            default:
                return print_r($item, true);
        }
    }
 /**
  * Checks post data and registers user
  * @return string
  */
 function register()
 {
     if (!empty($_REQUEST['register_ajax_widget'])) {
         $return = array();
         if ('POST' == $_SERVER['REQUEST_METHOD'] && !empty($_REQUEST['user_login']) && !empty($_REQUEST['user_email'])) {
             //require_once( ABSPATH . WPINC . '/registration.php');
             // todo - recaptcha
             $errors = register_new_user($_POST['user_login'], $_POST['user_email']);
             if (!is_wp_error($errors)) {
                 //Success
                 // do they have an envato id?
                 if (isset($_REQUEST['envato_purchase_code']) && !empty($_REQUEST['envato_purchase_code'])) {
                     // add this based on tc plugin.
                 }
                 $user_data = get_userdata($errors);
                 $return['result'] = true;
                 $return['message'] = __(sprintf('Thank you %s. Registration is complete. Please check your e-mail.', $user_data->user_login));
             } else {
                 //Something's wrong
                 $return['result'] = false;
                 $return['error'] = $errors->get_error_message() . "<br>Username: "******"/^jQuery[_a-zA-Z0-9]+\$/", $_REQUEST['callback'])) {
             $return = $_GET['callback'] . "({$return})";
         }
         echo $return;
         exit;
     }
 }
Exemplo n.º 10
0
 /**
  * Runs checks for necessary config options.
  *
  * @return void Method does not return.
  */
 public function run_checks()
 {
     $role = get_role('administrator');
     $current_user = get_userdata(get_current_user_id());
     if (!is_object($role) || !is_object($current_user) || !$role->has_cap('manage_ai1ec_options') || defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     global $plugin_page;
     $settings = $this->_registry->get('model.settings');
     $notification = $this->_registry->get('notification.admin');
     $notifications = array();
     // check if is set calendar page
     if (!$settings->get('calendar_page_id')) {
         $msg = Ai1ec_I18n::__('Select an option in the <strong>Calendar page</strong> dropdown list.');
         $notifications[] = $msg;
     }
     if ($plugin_page !== AI1EC_PLUGIN_NAME . '-settings' && !empty($notifications)) {
         if ($current_user->has_cap('manage_ai1ec_options')) {
             $msg = sprintf(Ai1ec_I18n::__('The plugin is installed, but has not been configured. <a href="%s">Click here to set it up now &raquo;</a>'), admin_url(AI1EC_SETTINGS_BASE_URL));
             $notification->store($msg, 'updated', 2, array(Ai1ec_Notification_Admin::RCPT_ADMIN));
         } else {
             $msg = Ai1ec_I18n::__('The plugin is installed, but has not been configured. Please log in as an Administrator to set it up.');
             $notification->store($msg, 'updated', 2, array(Ai1ec_Notification_Admin::RCPT_ALL));
         }
         return;
     }
     foreach ($notifications as $msg) {
         $notification->store($msg, 'updated', 2, array(Ai1ec_Notification_Admin::RCPT_ADMIN));
     }
 }
Exemplo n.º 11
0
function tdomf_get_admin_emails($form_id)
{
    global $wpdb;
    // grab email addresses
    $email_list = "";
    $notify_roles = tdomf_get_option_form(TDOMF_NOTIFY_ROLES, $form_id);
    if ($notify_roles != false) {
        if ($notify_roles != false) {
            $users = tdomf_get_all_users();
            $notify_roles = explode(';', $notify_roles);
            foreach ($users as $user) {
                $user = get_userdata($user->ID);
                if (!empty($user->user_email)) {
                    foreach ($notify_roles as $role) {
                        if (!empty($role) && isset($user->{$wpdb->prefix . 'capabilities'}[$role])) {
                            $email_list .= $user->user_email . ", ";
                            break;
                        }
                    }
                }
            }
        }
    }
    $more_emails = tdomf_get_option_form(TDOMF_OPTION_ADMIN_EMAILS, $form_id);
    if ($more_emails) {
        $email_list .= $more_emails;
    }
    return $email_list;
}
Exemplo n.º 12
0
function getWeekBlog()
{
    global $wpdb;
    $counter = 0;
    $posts = array();
    $blog = $wpdb->get_col("SELECT blogName FROM wp_weekblog WHERE endPublish >= CURRENT_DATE() AND initPublish <= CURRENT_DATE() AND active=1 ORDER BY endPublish limit 0,1");
    $blogd = $wpdb->get_col("SELECT description FROM wp_weekblog WHERE endPublish >= CURRENT_DATE() AND initPublish <= CURRENT_DATE() AND active=1 ORDER BY endPublish limit 0,1");
    if ($blog[0] == '') {
        return $posts;
    }
    if (!file_exists(bloginfo('template_directory') . '/images/weekblog/' . $blog[0] . '.png')) {
        return $posts;
    }
    $blogId = $wpdb->get_results("SELECT blog_id,domain,path from {$wpdb->blogs} WHERE path like '" . PATH_CURRENT_SITE . "{$blog['0']}/'");
    $blogOptionsTable = "wp_" . $blogId[0]->blog_id . "_options";
    $blogPostsTable = "wp_" . $blogId[0]->blog_id . "_posts";
    $options = $wpdb->get_results("SELECT option_value FROM {$blogOptionsTable} WHERE option_name IN ('siteurl','blogname') ORDER BY option_id, option_name DESC");
    $thispost = $wpdb->get_results("SELECT post_title, guid, post_content, post_date, post_author " . "FROM {$blogPostsTable} " . "WHERE post_status = 'publish' " . "AND post_title<>'' " . "AND post_type = 'post' " . "ORDER BY {$blogPostsTable}.id DESC limit 0,3");
    $thisusername = get_userdata($thispost[0]->post_author)->user_login;
    if ($thispost[1]->post_title == '') {
        return $posts;
    }
    $posts = array('title0' => $thispost[0]->post_title, 'title1' => $thispost[1]->post_title, 'guid0' => $thispost[0]->guid, 'guid1' => $thispost[1]->guid, 'blogTitle' => $options[1]->option_value, 'blogUrl' => $options[0]->option_value, 'imgName' => $blog[0], 'description' => $blogd[0]);
    return $posts;
}
Exemplo n.º 13
0
/**
 * If the user leaves certain meta info blank, forcefully fill it with our own
 *
 * @param int $pid
 * @param \WP_Post $post
 */
function add_required_data($pid, $post)
{
    $pb_author = get_post_meta($pid, 'pb_author', true);
    if (!$pb_author) {
        // if the pb_author metadata value is not set, set it to the primary book user's name
        if (0 !== get_current_user_id()) {
            /** @var $user_info \WP_User */
            $user_info = get_userdata(get_current_user_id());
            $name = $user_info->display_name;
            update_post_meta($pid, 'pb_author', $name);
        }
    }
    $pb_language = get_post_meta($pid, 'pb_language', true);
    if (!$pb_language) {
        // if the pb_language metadata value is not set, set it to the network default
        $locale = get_site_option('WPLANG');
        $locale = array_search($locale, \PressBooks\L10n\wplang_codes());
        if (!$locale) {
            $locale = 'en';
        }
        update_post_meta($pid, 'pb_language', $locale);
    }
    $pb_cover_image = get_post_meta($pid, 'pb_cover_image', true);
    if (!$pb_cover_image) {
        // if the pb_cover_image metadata value is not set, set it to the default image
        update_post_meta($pid, 'pb_cover_image', \PressBooks\Image\default_cover_url());
    }
}
Exemplo n.º 14
0
function load_member_page()
{
    $id = $_POST['id'];
    $current_member = get_userdata($id);
    include locate_template('template-part-member.php');
    die;
}
Exemplo n.º 15
0
function al_Main($atts)
{
    global $wpdb, $current_user, $al_lang, $post;
    $a = shortcode_atts(array('al_id' => $post->ID), $atts);
    $return = '<div id="al_table_cont_' . $a['al_id'] . '" class="al_table_cont">';
    if ($current_user->ID > 0) {
        $return .= '<table id="al_head_' . $a['al_id'] . '"><tr><td class="al_head"><strong>' . $al_lang['question'] . '</strong> </td><td class="al_head">' . '<a href="#" id="al_vote1_' . $a['al_id'] . '" title="1" class="al_btn al_btn_' . $a['al_id'] . '">' . $al_lang['vote1'] . '</a>&nbsp;' . '<a href="#" id="al_vote2_' . $a['al_id'] . '" title="2" class="al_btn al_btn_' . $a['al_id'] . '">' . $al_lang['vote2'] . '</a>&nbsp;' . '<a href="#" id="al_vote3_' . $a['al_id'] . '" title="3" class="al_btn al_btn_' . $a['al_id'] . '">' . $al_lang['vote3'] . '</a>&nbsp;&nbsp;&nbsp;' . '<span id="al_state_' . $a['al_id'] . '" class="al_state"></span></td></tr></table>';
        $wp_user_search = $wpdb->get_results("SELECT ID, display_name FROM {$wpdb->users} ORDER BY user_nicename");
        $return .= '<table id="al_head_' . $a['al_id'] . '"><tr><td class="al_head">';
        /*$return.= '<form name="formulaire">';*/
        $return .= '<select id="boite1" name="boite1" onChange=""> ';
        $return .= '<option selected value="-1">Choisissez un nom</option>  ';
        foreach ($wp_user_search as $userid) {
            $user_id = (int) $userid->ID;
            $user_info = get_userdata($user_id);
            if ($user_info->user_login != 'arruanais' && $user_info->user_login != 'admin') {
                $return .= '<option value="' . $user_id . '">' . $user_info->display_name . '</option> ';
            }
        }
        $return .= '</select>';
        $return .= '</td>';
        //$return .= '<td class="al_head"><strong>'.$al_lang['question2'].'</strong> </td>';
        $return .= '<td class="al_head">' . '<a href="#" id="al_vote1_' . $a['al_id'] . '" title="1" class="al_btn al_btn2_' . $a['al_id'] . '">' . $al_lang['vote1'] . '</a>&nbsp;' . '<a href="#" id="al_vote2_' . $a['al_id'] . '" title="2" class="al_btn al_btn2_' . $a['al_id'] . '">' . $al_lang['vote2'] . '</a>&nbsp;' . '<a href="#" id="al_vote3_' . $a['al_id'] . '" title="3" class="al_btn al_btn2_' . $a['al_id'] . '">' . $al_lang['vote3'] . '</a>&nbsp;&nbsp;&nbsp;' . '<span id="al_state2_' . $a['al_id'] . '" class="al_state"></span></td></tr></table>';
    } else {
        $return .= '<table><tr><td>' . $al_lang['login'] . '</td></tr></table>';
    }
    $return .= '<div id="al_cont_' . $a['al_id'] . '">' . al_DrawList($a['al_id']) . '</div></div>';
    $return .= "<script language='javascript'>\n\tjQuery(document).ready(function(){\n\t  jQuery('.al_btn_" . $a['al_id'] . "').click(function() {\n\t  \tjQuery('#al_state_" . $a['al_id'] . "').html('<img src=\"" . get_bloginfo('wpurl') . "/wp-content/plugins/attendance-list/img/ajax-loader.gif\" />');\n\t    param=jQuery(this).attr('title');\n\t    jQuery.post('" . get_bloginfo('wpurl') . "/wp-content/plugins/attendance-list/response.php', { al_vote: param, al_postid:" . $a['al_id'] . ", al_user_ID:" . $current_user->ID . " }, \n\t    function(data){ \n\t      if(data) {\n\t\t\tjQuery('#al_cont_" . $a['al_id'] . "').html(data);\n\t\t\tjQuery('#al_state_" . $a['al_id'] . "').html('');\n\t      }\n\t    }, \n\t    'html');\n\t    return false;\n\t  });\n\t\n\t   jQuery('.al_btn2_" . $a['al_id'] . "').click(function() {\n\t\tvar e = document.getElementById('boite1');\n\t\tvar strUser = e.options[e.selectedIndex].value;\n\t  \tjQuery('#al_state2_" . $a['al_id'] . "').html('<img src=\"" . get_bloginfo('wpurl') . "/wp-content/plugins/attendance-list/img/ajax-loader.gif\" />');\n\t    \tparam=jQuery(this).attr('title');\n\t    \tjQuery.post('" . get_bloginfo('wpurl') . "/wp-content/plugins/attendance-list/response.php', { al_vote: param, al_postid:" . $a['al_id'] . ", al_user_ID: strUser }, \n\t    \tfunction(data){ \n\t      \t\tif(data) {\n\t\t\t\tjQuery('#al_cont_" . $a['al_id'] . "').html(data);\n\t\t\t\tjQuery('#al_state2_" . $a['al_id'] . "').html('');\n\t      \t\t}\n\t    \t}, \n\t    \t'html');\n\t    return false;\n\t  });\n\t});\n\t</script>";
    return $return;
}
Exemplo n.º 16
0
 public static function getUserGroups($userId)
 {
     global $wpdb;
     $user = get_userdata($userId);
     $capabilities = $user->{$wpdb->prefix . 'capabilities'};
     return !empty($capabilities) ? $capabilities : array();
 }
Exemplo n.º 17
0
function add_new_bookmark()
{
    if (!current_user_can('publish_posts')) {
        wp_redirect(get_bloginfo('url'));
        exit;
    }
    check_admin_referer('new-post');
    $user = get_userdata($current_user->ID);
    $post_title = urldecode($_POST['posttitle']);
    $post_url = urldecode($_POST['posturl']);
    $post_content = urldecode($_POST['posttext']);
    $tags = urldecode($_POST['tags']);
    $status = urldecode($_POST['status']);
    global $wpdb;
    // Search existing post with this pressmark-url
    $existing_post_id = $wpdb->get_var("SELECT post_id FROM {$wpdb->postmeta} \n\t\t\t\t\t\t\t\t\tWHERE meta_key = 'pressmark-url' AND meta_value = '{$post_url}'");
    if ($existing_post_id) {
        // If exists, add coauthor
        add_post_meta($existing_post_id, 'coauthor', (int) $user->ID, false);
        // Place post on top
        $post_modified = current_time('mysql');
        $post_modified_gmt = current_time('mysql', 1);
        $wpdb->query("UPDATE {$wpdb->posts} \n\t\t\t\t\tSET post_date = {$post_modified} \n\t\t\t\t\tSET post_date_gmt = {$post_modified_gmt}\n\t\t\t\t\tWHERE ID = '{$existing_post_id}'");
    } else {
        // If not exists, insert new post
        $post_id = wp_insert_post(array('post_author' => $user->ID, 'post_title' => $post_title, 'post_content' => $post_content, 'tags_input' => $tags, 'post_status' => $status));
        $wpdb->query("\n\t\t\t\tINSERT INTO {$wpdb->postmeta}\n\t\t\t\t(post_id,meta_key,meta_value )\n\t\t\t\tVALUES ('{$post_id}','pressmark-url','{$post_url}' )\n\t\t\t");
    }
}
 function get_actor($actor_id, $actor_type = null, $args = null)
 {
     if ($actor_type == null) {
         $actor_type = 'user';
     }
     $object = null;
     if ($actor_id != null) {
         switch ($actor_type) {
             case 'user':
                 $object = get_userdata($actor_id);
                 if ($object == false) {
                     $object = null;
                 }
                 break;
             case 'role':
                 $object = get_role($actor_id);
                 if ($object == false) {
                     $object = null;
                 }
                 break;
         }
     }
     if ($object != null) {
         $factory = $this->get_registry()->get_utility('I_Component_Factory');
         $actor = $factory->create('wordpress_security_actor', $actor_type);
         $entity_props = array('type' => $actor_type, 'id' => $actor_id);
         $actor->set_entity($object, $entity_props);
         return $actor;
     }
     return $this->object->get_guest_actor();
 }
Exemplo n.º 19
0
/**
 * Checks to see if the the specified user is author of the current global post or post (if specified)
 * @param object|int $user
 * @param int $post_id
 */
function is_coauthor_for_post($user, $post_id = 0)
{
    global $post;
    if (!$post_id && $post) {
        $post_id = $post->ID;
    }
    if (!$post_id) {
        return false;
    }
    if (!$user) {
        return false;
    }
    $coauthors = get_coauthors($post_id);
    if (is_numeric($user)) {
        $user = get_userdata($user);
        $user = $user->user_login;
    } else {
        if (isset($user->user_login)) {
            $user = $user->user_login;
        } else {
            return false;
        }
    }
    foreach ($coauthors as $coauthor) {
        if ($user == $coauthor->user_login || $user == $coauthor->linked_account) {
            return true;
        }
    }
    return false;
}
function friends_notification_accepted_request($friendship_id, $initiator_id, $friend_id)
{
    $friend_name = bp_core_get_user_displayname($friend_id);
    if ('no' == bp_get_user_meta((int) $initiator_id, 'notification_friends_friendship_accepted', true)) {
        return false;
    }
    $ud = get_userdata($initiator_id);
    $friend_link = bp_core_get_user_domain($friend_id);
    $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
    $settings_link = trailingslashit(bp_core_get_user_domain($initiator_id) . $settings_slug . '/notifications');
    // Set up and send the message
    $to = $ud->user_email;
    $subject = bp_get_email_subject(array('text' => sprintf(__('%s accepted your friendship request', 'buddypress'), $friend_name)));
    $message = sprintf(__('%1$s accepted your friend request.

To view %2$s\'s profile: %3$s

---------------------
', 'buddypress'), $friend_name, $friend_name, $friend_link);
    // Only show the disable notifications line if the settings component is enabled
    if (bp_is_active('settings')) {
        $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
    }
    /* Send the message */
    $to = apply_filters('friends_notification_accepted_request_to', $to);
    $subject = apply_filters('friends_notification_accepted_request_subject', $subject, $friend_name);
    $message = apply_filters('friends_notification_accepted_request_message', $message, $friend_name, $friend_link, $settings_link);
    wp_mail($to, $subject, $message);
    do_action('bp_friends_sent_accepted_email', $initiator_id, $subject, $message, $friendship_id, $friend_id);
}
Exemplo n.º 21
0
/**
 * Display custom columns for RSS Feeds
 *
 * @param $column
 * @param $post_id
 */
function rssmi_show_custom_columns($column, $post_id)
{
    global $wpdb;
    switch ($column) {
        case 'url':
            $url = get_post_meta($post_id, 'rssmi_url', true);
            echo '<a href="' . esc_url($url) . '">' . esc_url($url) . '</a>';
            break;
        case 'category':
            $category = get_post_meta($post_id, 'rssmi_cat', true);
            echo esc_html(wp_getCategoryName($category));
            break;
        case 'bloguser':
            $bloguser = get_post_meta($post_id, 'rssmi_user', true);
            $bloguser = (int) $bloguser;
            echo esc_html(get_userdata($bloguser)->display_name);
            break;
        case 'feeditems':
            $post_count = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM (SELECT * from {$wpdb->postmeta} as a inner join {$wpdb->posts} as b on b.id=a.post_id where meta_key='rssmi_item_feed_id' and meta_value=%d order by post_id desc LIMIT 25) as c order by post_id ASC", $post_id));
            echo $post_count;
            break;
        case 'lastupdate':
            if (get_post_meta($post_id, 'rssmi_last_update', true) != '') {
                $last_update = get_post_meta($post_id, 'rssmi_last_update', true);
                echo get_date_from_gmt(date('Y-m-d H:i:s', $last_update), 'M j, Y @ g:i a  ');
            } else {
                echo "No Recent Update Yet";
            }
            break;
        case 'ID':
            echo $post_id;
            break;
    }
}
 function TS_VCSC_CheckUserRole($roles, $user_id = NULL)
 {
     // Get user by ID, else get current user
     if ($user_id) {
         $user = get_userdata($user_id);
     } else {
         $user = wp_get_current_user();
     }
     // No user found, return
     if (empty($user)) {
         return FALSE;
     }
     // Append administrator to roles, if necessary
     if (!in_array('administrator', $roles)) {
         $roles[] = 'administrator';
     }
     // Loop through user roles
     foreach ($user->roles as $role) {
         // Does user have role
         if (in_array($role, $roles)) {
             return TRUE;
         }
     }
     // User not in roles
     return FALSE;
 }
function list_cp_users()
{
    global $wpdb;
    $cp_proj_table_name = $wpdb->prefix . "cp_projects";
    $cp_tasks_table_name = $wpdb->prefix . "cp_tasks";
    $cp_list_users = $wpdb->get_results("SELECT auth FROM {$cp_proj_table_name} UNION SELECT users FROM {$cp_tasks_table_name}");
    if ($cp_list_users) {
        foreach ($cp_list_users as $cp_list_user) {
            $user_info = get_userdata($cp_list_user->auth);
            echo '<div id="cp-gravatar" style="height:62px;width:62px;background:#F0F0F0;">';
            // Default gravatar
            $def_gravatar = "http://www.gravatar.com/avatar/c11f04eee71dfd0f49132786c34ea4ff?s=50&d=&r=G&forcedefault=1";
            // User link
            echo '<a href="admin.php?page=cp-dashboard-page&view=userpage&user='******'">';
            // Get gravatar
            echo get_avatar($user_info->user_email, $size = '50', $default = $def_gravatar);
            echo '</a>';
            echo '</div>';
            echo '<div id="cp-task-summary">';
            // User link
            echo '<a href="admin.php?page=cp-dashboard-page&view=userpage&user='******'">';
            // Display username
            echo '<p><strong>' . $user_info->user_nicename . '</strong></p>';
            echo '</a>';
            echo '</div>';
        }
    } else {
        // There are no users yet
        echo "<p>No users...</p>";
    }
}
Exemplo n.º 24
0
/**
 * Sets the authordata global when viewing an author archive.
 *
 * This provides backwards compatibility with
 * http://core.trac.wordpress.org/changeset/25574
 *
 * It removes the need to call the_post() and rewind_posts() in an author
 * template to print information about the author.
 *
 * @author Automattic
 * @author Cherry Team <*****@*****.**>
 * @since  4.0.0
 * @global WP_Query $wp_query WordPress Query object.
 * @return void
 */
function cherry_setup_author()
{
    global $wp_query;
    if ($wp_query->is_author() && isset($wp_query->post)) {
        $GLOBALS['authordata'] = get_userdata($wp_query->post->post_author);
    }
}
Exemplo n.º 25
0
 function mailchimp_ultimate_fb_add_user($uid, $registration, $me)
 {
     global $mailchimp_sync;
     $user = get_userdata($uid);
     $user_arr = array('email' => $user->user_email, 'first_name' => $me['first_name'], 'last_name' => $me['last_name']);
     $mailchimp_sync->mailchimp_add_user($user_arr);
 }
Exemplo n.º 26
0
 public function __construct($post_id = 0)
 {
     // Ajax Actions
     add_action('wp_ajax_nopriv_set_rating', array($this, 'ajax_ratings_callback'));
     add_action('wp_ajax_set_rating', array($this, 'ajax_ratings_callback'));
     // Filters
     add_filter('javo_rating_score_display', array('javo_rating', 'javo_rating_score_display_callback'), 10, 3);
     add_filter('javo_rating_alert_strings', array('javo_rating', 'javo_rating_alert_strings_callback'), 10, 3);
     // Timeline More Content
     add_action('wp_ajax_nopriv_get_timeline', array($this, 'get_timeline_callback'));
     add_action('wp_ajax_get_timeline', array($this, 'get_timeline_callback'));
     add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts_callback'));
     // Post Action
     add_action('before_delete_post', array($this, 'update_score'), 10, 2);
     add_action('save_post', array($this, 'update_score'), 10, 2);
     // Change Status
     add_action('wp_insert_post', array($this, 'update_score_trigger'), 10, 3);
     if ((int) $post_id <= 0) {
         return;
     }
     global $javo_tso;
     // Initialize Variables.
     $this->post = get_post($post_id);
     $this->author = get_userdata($this->post->post_author);
     $this->rating_fields = $javo_tso->get('rating_field');
     $this->need_login = $javo_tso->get('rating_logged_enable', NULL);
     $this->alert_strings = apply_filters('javo_rating_alert_strings', null);
     $this->parent_rating_total = (double) get_post_meta($this->post->ID, 'rating_total', true);
     $this->parent_rating_average = (double) get_post_meta($this->post->ID, 'rating_average', true);
     $this->parent_rating_count = (double) get_post_meta($this->post->ID, 'rating_count', true);
     $this->parent_rating_average_star = array('fa fa-star-o', 'fa fa-star-o', 'fa fa-star-o', 'fa fa-star-o', 'fa fa-star-o');
     for ($i = 0; $i < round((double) $this->parent_rating_average); $i++) {
         $this->parent_rating_average_star[$i] = 'fa fa-star';
     }
 }
Exemplo n.º 27
0
 /**
  * Displaying Prodcuts
  *
  * Does prepare the data for displaying the products in the table.
  */
 function display_seller_review()
 {
     $data = array();
     $prefix = FARMTOYOU_META_PREFIX;
     //if search is call then pass searching value to function for displaying searching values
     $args = array('post_type' => FARMTOYOU_SELLER_REVIEW_POST_TYPE, 'post_status' => 'any', 'posts_per_page' => '-1');
     //get seller_review data from database
     $all_seller_review = get_posts($args);
     foreach ($all_seller_review as $key => $value) {
         $seller_id = get_post_meta($value->ID, $prefix . 'seller_id', true);
         $store_info = dokan_get_store_info($seller_id);
         $store_name = isset($store_info['store_name']) ? esc_html($store_info['store_name']) : __('N/A', 'dokan');
         $curr_user_id = get_post_meta($value->ID, $prefix . 'current_user_id', true);
         $user_info = get_userdata($curr_user_id);
         $first_name = $user_info->first_name;
         $last_name = $user_info->last_name;
         $user_email = $user_info->user_email;
         $data[$key]['ID'] = isset($value->ID) ? $value->ID : '';
         $data[$key]['seller_store'] = $store_name;
         $data[$key]['curr_user_name'] = $first_name . " " . $last_name;
         $data[$key]['curr_user_email'] = $user_email;
         $data[$key]['user_rating'] = get_post_meta($value->ID, $prefix . 'seller_rating', true);
         $data[$key]['user_comment'] = get_post_meta($value->ID, $prefix . 'user_comment', true);
         $data[$key]['post_status'] = isset($value->post_status) ? $value->post_status : '';
         $data[$key]['post_date'] = isset($value->post_date) ? $value->post_date : '';
     }
     return $data;
 }
Exemplo n.º 28
0
 public function get_attachments()
 {
     global $json_api;
     global $user_ID;
     // todo
     // support attachments by user
     // support attachments by post (this is supported)
     // support returning no attachments if user is not logged in
     // support returning all attachments for parent and it's descendents
     if (is_user_logged_in()) {
         $loggedIn = (bool) true;
     } else {
         $loggedIn = (bool) false;
     }
     if ($loggedIn) {
         $user = get_userdata($user_ID);
     }
     if ($json_api->query->parent !== "null") {
         $parent = (int) $json_api->query->parent;
     } else {
         $parent = null;
     }
     // we should check if the file the attachments are part of are published or not
     $attachments = $json_api->introspector->get_attachments($parent);
     $output = array('count' => count($attachments), 'attachments' => $attachments);
     return $output;
 }
/**
 * Notification functions are used to send email notifications to users on specific events
 * They will check to see the users notification settings first, if the user has the notifications
 * turned on, they will be sent a formatted email notification. 
 *
 * You should use your own custom actions to determine when an email notification should be sent.
 */
function bp_zoneideas_send_high_five_notification($to_user_id, $from_user_id)
{
    global $bp;
    /* Let's grab both user's names to use in the email. */
    $sender_name = bp_fetch_user_fullname($from_user_id, false);
    $reciever_name = bp_fetch_user_fullname($to_user_id, false);
    /* We need to check to see if the recipient has opted not to recieve high-five emails */
    if ('no' == get_usermeta((int) $to_user_id, 'notification_zoneideas_new_high_five')) {
        return false;
    }
    /* Get the userdata for the reciever and sender, this will include usernames and emails that we need. */
    $reciever_ud = get_userdata($to_user_id);
    $sender_ud = get_userdata($from_user_id);
    if (!$bp->profile->slug) {
        $bp->profile->slug = 'profile';
    }
    /* Now we need to construct the URL's that we are going to use in the email */
    $sender_profile_link = site_url(MEMBERS_SLUG . '/' . $sender_ud->user_login . '/' . $bp->profile->slug);
    $sender_highfive_link = site_url(MEMBERS_SLUG . '/' . $sender_ud->user_login . '/' . $bp->zoneideas->slug . '/screen-one');
    $reciever_settings_link = site_url(MEMBERS_SLUG . '/' . $reciever_ud->user_login . '/settings/notifications');
    /* Set up and send the message */
    $to = $reciever_ud->user_email;
    $subject = sprintf(__('%s high-fived you!', 'bp-zoneideas'), $sender_name);
    $message = sprintf(__('%s sent you a high-five! Why not send one back?

To see %s\'s profile: %s

To send %s a high five: %s

---------------------
', 'bp-zoneideas'), $sender_name, $sender_name, $sender_profile_link, $sender_name, $sender_highfive_link);
    $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'bp-zoneideas'), $reciever_settings_link);
    // Send it!
    wp_mail($to, $subject, $message);
}
 function get_permalink($id = false)
 {
     $rewritecode = array('%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', '%postname%', '%post_id%', '%category%', '%author%', '%pagename%');
     $permalink = get_settings('permalink_structure');
     $postHandler =& wp_handler('Post');
     if ($id) {
         $id = intval($id);
         if ($permalink == '') {
             return wp_siteurl() . '/index.php?p=' . $id;
         }
         if (!isset($GLOBALS['permalink_cache'][wp_id()]) || !isset($GLOBALS['permalink_cache'][wp_id()][$id])) {
             $postObject =& $postHandler->get($id);
             $GLOBALS['permalink_cache'][wp_id()][$id] =& $postObject->exportWpObject();
         }
         $idpost = $GLOBALS['permalink_cache'][wp_id()][$id];
     } else {
         $idpost = $GLOBALS['post'];
     }
     if ('' != $permalink) {
         $unixtime = strtotime($idpost->post_date);
         $cats = get_the_category($idpost->ID);
         $category = $cats[0]->category_nicename;
         $authordata = get_userdata($idpost->post_author);
         $author = $authordata->user_login;
         $rewritereplace = array(date('Y', $unixtime), date('m', $unixtime), date('d', $unixtime), date('H', $unixtime), date('i', $unixtime), date('s', $unixtime), $idpost->post_name, $idpost->ID, $category, $author, $idpost->post_name);
         return wp_siteurl() . str_replace($rewritecode, $rewritereplace, $permalink);
     } else {
         return wp_siteurl() . '/index.php?p=' . $idpost->ID;
     }
 }