Social Buttons instead.'; } function tumblr_add_button() { global $conf, $template, $page; $conf['TumblrShare'] = unserialize($conf['TumblrShare']); $conf['TumblrShare']['css'] = array( 'share_1' => 'width:81px; height:20px;', 'share_2' => 'width:61px; height:20px;', 'share_3' => 'width:129px; height:20px;', 'share_4' => 'width:20px; height:20px;', 'share_1T' => 'width:81px; height:20px;', 'share_2T' => 'width:61px; height:20px;', 'share_3T' => 'width:129px; height:20px;', 'share_4T' => 'width:20px; height:20px;', ); $root_url = get_absolute_root_url(); // button on piture page if (script_basename() == 'picture') { global $picture; $template->assign(array( 'TUMBLR_MODE' => 'photo', 'TUMBLR_URL' => $root_url.ltrim(duplicate_picture_url(), './'), 'TUMBLR_TITLE' => $picture['current']['TITLE'], )); if ($conf['TumblrShare']['img_size'] == 'Original') { $template->assign('TUMBLR_SOURCE', $root_url.ltrim($picture['current']['src_image']->get_url(), './')); } else { $template->assign('TUMBLR_SOURCE', $root_url.ltrim(DerivativeImage::url($conf['TumblrShare']['img_size'], $picture['current']['src_image']), './')); } } // button on other pages else if (script_basename() == 'index') { $conf['TumblrShare']['position'] = 'index'; $template->assign(array( 'TUMBLR_MODE' => 'link', 'TUMBLR_URL' => $root_url.ltrim(duplicate_index_url(), './'), 'TUMBLR_TITLE' => strip_tags($page['title']), )); } else { return; } // config $template->assign(array( 'TUMBLR_POSITION' => $conf['TumblrShare']['position'], 'TUMBLR_TYPE' => $conf['TumblrShare']['type'], 'TUMBLR_CSS' => $conf['TumblrShare']['css'][ $conf['TumblrShare']['type'] ], 'TUMBLR_COPY' => ' (from '.$conf['gallery_title'].')', )); $template->set_filename('tumblr_button', dirname(__FILE__).'/button.tpl'); $button = $template->parse('tumblr_button', true); switch ($conf['TumblrShare']['position']) { case 'index': // $template->add_index_button('
  • '.$button.'
  • ', 100); $template->concat('PLUGIN_INDEX_ACTIONS', '
  • '.$button.'
  • '); break; case 'toolbar': // $template->add_picture_button($button, 100); $template->concat('PLUGIN_PICTURE_ACTIONS', $button); break; default; $template->assign('TUMBLR_BUTTON', $button); $template->set_prefilter('picture', 'tumblr_add_button_prefilter'); } } function tumblr_add_button_prefilter($content, &$smarty) { global $template; switch ($template->get_template_vars('TUMBLR_POSITION')) { case 'top': $search = '
    '; $replace = '
    {$TUMBLR_BUTTON}
    '; break; case 'bottom': $search = '{$ELEMENT_CONTENT}'; $replace = '{$TUMBLR_BUTTON}'; break; } return str_replace($search, $search.$replace, $content); } if (script_basename() == 'admin') { add_event_handler('get_admin_plugin_menu_links', 'tumblr_plugin_admin_menu'); function tumblr_plugin_admin_menu($menu) { array_push($menu, array( 'NAME' => 'tumblr.share', 'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__)) )); return $menu; } } ?>