Exemple #1
0
function post_parsed($imonggo_inventory, $imonggo_products, $url_shopify, $http_header_post, $http_header_pull, $pull_url_shopify)
{
    if (isset($_POST['submit'])) {
        $tags = $_POST['checkbox'];
        // if any of the tags is checked
        $notag = $_POST['notag'];
        // if no tag checkbox is checked
        $parsed = array();
        if (count($tags) > 0) {
            parse_tags($imonggo_inventory, $imonggo_products, $tags, $parsed, $url_shopify, $http_header_post, $http_header_pull, $pull_url_shopify);
            //if any of the tags is checked
            if (count($notag) > 0) {
                parse_notags($imonggo_inventory, $imonggo_products, $parsed, $url_shopify, $http_header_post, $http_header_pull, $pull_url_shopify);
            }
            //if any of the tags AND "no tag" checkboxes are checked
        } else {
            if (count($notag) > 0 && count($tags) < 1) {
                // if "no tag" checkbox is checked and no other tags are checked
                parse_notags($imonggo_inventory, $imonggo_products, $parsed, $url_shopify, $http_header_post, $http_header_pull, $pull_url_shopify);
            } else {
                echo "<br><hr>Please select at least one tag";
            }
        }
    }
}
 /**
  * 完整xml
  * @param  默认缓存时间为8个小时
  * @return string 
  */
 private function completeInfo($type, $denytag, $contentStr)
 {
     $taglist = parse_tags($denytag, $type);
     foreach ($taglist as $key => $value) {
         if ($value == 0) {
             $contentStr = str_replace('<amango:' . $value . 'tag>', '', $contentStr);
         }
     }
     $contentStr = preg_replace_callback("/(<amango:[^>]+>)/", "xml_parse_tags", $contentStr);
     //清除 未解析标签-
     $preg = '/<amango:[^>]+>/';
     //通用字符转义
     $content = escape_common(preg_replace($preg, '', $contentStr));
     //emoji表情处理
     return emoji($content);
 }
function update_picture_tags($picture_id, $tags)
{
    global $config;
    global $TABLE_PREFIX;
    $tags = parse_tags($tags);
    $picture_id = intval($picture_id);
    /* Process any tags for the picture */
    $existing_tags = $existing_rels = array();
    if (sizeof($tags) > 0) {
        $tagsql = join('", "', $tags);
        $sql = 'SELECT * FROM ' . $TABLE_PREFIX . 'tags WHERE `tag` IN ("' . $tagsql . '")';
        $result = mysql_query($sql);
        while ($tag_row = mysql_fetch_assoc($result)) {
            $existing_tags[$tag_row['tag']] = $tag_row['id'];
        }
        $sql = 'SELECT * FROM ' . $TABLE_PREFIX . 'tag2picture WHERE `picture_id` ="' . $picture_id . '"';
        $result = mysql_query($sql);
        while ($tag_row = mysql_fetch_assoc($result)) {
            $existing_rels[$tag_row['tag_id']] = $tag_row['picture_id'];
        }
    }
    foreach ($tags as $tag) {
        if (!isset($existing_tags[$tag])) {
            // Must be a new tag, register it
            $path = mysql_real_escape_string(preg_replace("/[^\\w|\\.|'|\\-|\\[|\\]]/", "_", $tag));
            $sql = 'INSERT INTO ' . $TABLE_PREFIX . 'tags (`tag`, `tagdate`, `path`)
			VALUES ("' . mysql_real_escape_string($tag) . '", "' . $path . '", NOW())';
            print $sql;
            $result = mysql_query($sql);
            $existing_tags[$tag] = mysql_insert_id();
        }
        if (!isset($existing_rels[$existing_tags[$tag]])) {
            // No connection between tag and picture? create if
            $sql = 'INSERT INTO ' . $TABLE_PREFIX . 'tag2picture (`picture_id`, `tag_id`, `tagdate`)
			VALUES ("' . $picture_id . '", "' . $existing_tags[$tag] . '", NOW())';
            mysql_query($sql);
        }
    }
    // Now remove links to any tags that have been deleted
    foreach ($existing_rels as $tag_id => $pic_id) {
        if (!in_array($tag_id, $existing_tags)) {
            $sql = "DELETE FROM `" . $TABLE_PREFIX . "tag2picture`\n\t\t\tWHERE `picture_id` = '{$picture_id}' AND `tag_id` = '{$tag_id}'";
            mysql_query($sql);
        }
    }
}
/**
 * Email all admins when post status changes to pending
 *
 * @since 1.0.0
 */
function author_send_email($new_status, $old_status, $post)
{
    /**
     *
     */
    //$settings = get_option('author_notifier_settings');
    $settings = false;
    // Default values
    if ($settings === false) {
        $settings = default_data();
    }
    $default_data = default_data();
    $settings['message'] = array('cc_email' => $settings['message']['cc_email'] != '' ? $settings['message']['cc_email'] : $default_data['message']['cc_email'], 'bcc_email' => $settings['message']['bcc_email'] != '' ? $settings['message']['bcc_email'] : $default_data['message']['bcc_email'], 'from_email' => $settings['message']['from_email'] != '' ? $settings['message']['from_email'] : $default_data['message']['from_email'], 'subject_published' => $settings['message']['subject_published'] != '' ? $settings['message']['subject_published'] : $default_data['message']['subject_published'], 'subject_published_contributor' => $settings['message']['subject_published_contributor'] != '' ? $settings['message']['subject_published_contributor'] : $default_data['message']['subject_published_contributor'], 'subject_pending' => $settings['message']['subject_pending'] != '' ? $settings['message']['subject_pending'] : $default_data['message']['subject_pending'], 'content_published' => $settings['message']['content_published'] != '' ? $settings['message']['content_published'] : $default_data['message']['content_published'], 'content_published_contributor' => $settings['message']['content_published_contributor'] != '' ? $settings['message']['content_published_contributor'] : $default_data['message']['content_published_contributor'], 'content_pending' => $settings['message']['content_pending'] != '' ? $settings['message']['content_pending'] : $default_data['message']['content_pending'], 'share_links' => array('twitter' => $settings['message']['share_links']['twitter'], 'facebook' => $settings['message']['share_links']['facebook'], 'google' => $settings['message']['share_links']['google'], 'linkedin' => $settings['message']['share_links']['linkedin']));
    // If status did not change
    if ($new_status == $old_status) {
        return null;
    }
    // Set all headers
    $headers = array();
    if (isset($settings['message']['from_email']) && $settings['message']['from_email'] != '') {
        $headers[] = "From: " . $settings['message']['from_email'] . "\r\n";
    }
    if (isset($settings['message']['cc_email']) && $settings['message']['cc_email'] != '') {
        $headers[] = "Cc: " . $settings['message']['cc_email'] . "\r\n";
    }
    if (isset($settings['message']['bcc_email']) && $settings['message']['bcc_email'] != '') {
        $headers[] = "Bcc: " . $settings['message']['bcc_email'] . "\r\n";
    }
    if (isset($settings['message']['share_links'])) {
        $check = false;
        foreach ($settings['message']['share_links'] as $link) {
            if ($link) {
                $share_links_check = true;
            }
        }
    }
    $url = get_permalink($post->ID);
    $share_links = '';
    /**
     * Add sharing links are set
     */
    if (isset($share_links_check) && $share_links_check) {
        $share_links = "\r\n\r\nShare Links\r\n";
        if ($settings['message']['share_links']['twitter']) {
            $share_links .= "Twitter: " . esc_url('https://twitter.com/intent/tweet?url=' . $url) . "\r\n";
        }
        if ($settings['message']['share_links']['facebook']) {
            $share_links .= "Facebook: " . esc_url('https://www.facebook.com/sharer/sharer.php?u=' . $url) . "\r\n";
        }
        if ($settings['message']['share_links']['google']) {
            $share_links .= "Google+: " . esc_url('https://plus.google.com/share?url=' . $url) . "\r\n";
        }
        if ($settings['message']['share_links']['linkedin']) {
            $share_links .= "LinkedIn: " . esc_url('https://www.linkedin.com/shareArticle?url=' . $url) . "\r\n";
        }
    }
    // Notifiy Author that he/she has written a post
    if (in_array($post->post_type, $settings['post_types']) && $new_status == 'pending') {
        $url = get_permalink($post->ID);
        $edit_link = get_edit_post_link($post->ID, '');
        $preview_link = get_permalink($post->ID) . '&preview=true';
        $username = get_userdata($post->post_author);
        $author_email = $username->user_email;
        $subject = parse_tags($post, $username, $settings['message']['subject_pending']);
        $message = parse_tags($post, $username, $settings['message']['content_pending']);
        $message .= "\r\n\r\n";
        $message .= "Dear {$username->display_name}," . "\r\n";
        $message .= "Thank you for submitting your article to Charismedica. This is a confirmation email for your records. ";
        $message .= "Please find below information on your article. \r\n \r\n";
        $message .= "ID: {$post->ID} \r\n";
        $message .= "Title: {$post->post_title} \r\n";
        $message .= "Abstract: {$post->post_content} \r\n\r\n";
        $message .= "This is an automatically generated email. Please do not respond to it directly. ";
        $message .= "For questions regarding your submission, visit our contact page to get in touch with us. \r\n\r\n";
        $message .= "Best regards, \r\n";
        $message .= "Charismedica";
        $result = wp_mail($author_email, $subject, $message, $headers);
    }
    // Notifiy Author when their work is published
    if (in_array($post->post_type, $settings['post_types']) && $new_status == 'publish') {
        // Notify Author that their post was published
        if (isset($settings['publish_notify']) && $settings['publish_notify'] == 'author' && $old_status == 'pending' && user_can($post->post_author, 'edit_posts') && !user_can($post->post_author, 'publish_posts')) {
            $username = get_userdata($post->post_author);
            $subject = parse_tags($post, get_userdata($post->post_author), $settings['message']['subject_published_contributor']);
            $message .= "Dear {$username->display_name}," . "\r\n";
            $message .= "Congratulations! Your article was reviewed by our staff and accepted! ";
            $message .= "Please find below information on your article. \r\n \r\n";
            $message .= "ID: {$post->ID} \r\n";
            $message .= "Title: {$post->post_title} \r\n";
            $message .= "Abstract: {$post->post_content} \r\n\r\n";
            $message .= parse_tags($post, get_userdata($post->post_author), $settings['message']['content_published_contributor']);
            $message .= "This is an automatically generated email. Please do not respond to it directly. ";
            $message .= "For questions regarding your submission, visit our contact page to get in touch with us. \r\n\r\n";
            $message .= "Best regards, \r\n";
            $message .= "Charismedica";
            $message .= $share_links;
            $result = wp_mail($username->user_email, $subject, $message, $headers);
        }
        // Notify All Admins or All Users
    }
}