Exemplo n.º 1
0
 function tfuse_img_content()
 {
     $content = $link = '';
     $args = array('numberposts' => -1);
     $posts_array = get_posts($args);
     $option_name = 'thumbnail_image';
     foreach ($posts_array as $post) {
         $featured = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID));
         if (tfuse_page_options('thumbnail_image', false, $post->ID)) {
             continue;
         }
         if (!empty($featured)) {
             $value = $featured[0];
             tfuse_set_page_option($option_name, $value, $post->ID);
             tfuse_set_page_option('disable_image', true, $post->ID);
         } else {
             $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_parent' => $post->ID);
             $attachments = get_posts($args);
             if ($attachments) {
                 foreach ($attachments as $attachment) {
                     $value = $attachment->guid;
                     tfuse_set_page_option($option_name, $value, $post->ID);
                     tfuse_set_page_option('disable_image', true, $post->ID);
                 }
             } else {
                 $content = $post->post_content;
                 if (!empty($content)) {
                     preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $content, $matches);
                     if (!empty($matches)) {
                         $link = $matches[1];
                         tfuse_set_page_option($option_name, $link, $post->ID);
                         tfuse_set_page_option('disable_image', true, $post->ID);
                     }
                 }
             }
         }
     }
     tfuse_set_option('enable_content_img', false, $cat_id = NULL);
 }
Exemplo n.º 2
0
function _tfuse_fix_new_options_negate($options, $type)
{
    if ($type != 'admin' || !get_option(TF_THEME_PREFIX . '_tfuse_framework_options')) {
        return $options;
    }
    static $called = false;
    if ($called) {
        return $options;
    }
    $called = true;
    global $TFUSE;
    $negateOldOptions = array('disable_tfuse_seo_tab' => 'enable_tfuse_seo_tab', 'deactivate_tfuse_style' => 'activate_tfuse_style');
    $tp = TF_THEME_PREFIX . '_';
    $adminOptions = tf_only_options($options);
    foreach ($negateOldOptions as $oldId => $newId) {
        if (isset($adminOptions[$tp . $newId])) {
            // new id exists in options (this is new theme)
            if (tfuse_options($newId) === null) {
                // new id is not set
                // set it with negated old value
                tfuse_set_option($newId, !(bool) tfuse_options($oldId));
            }
        } else {
            // new id does not exists in options (this is old theme)
            // set it with negated old value
            // (verifications in code by this options id to work properly (emulate it exists))
            tfuse_set_option($newId, !(bool) tfuse_options($oldId));
        }
    }
    return $options;
}