Luciallo
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: [Cite] Is possible to add a short URL to the field list?Hello!
I was also looking for this and I found a way around it after stumbling on this thread (and some trial and error)! Thank you Miquel!
I didn’t use a Short URL plugin, but instead I’d call for the bloginfo and the article’s ID to create a custom shortlink that includes the website and not the wp.me…
Here is a summary of all changes I made in the plugin:
1. In Default Settings, I added {shortlink} after {permalink} :// Default settings $wpcp_default = apply_filters('wpcp_default_setting', array( 'setting' => __('Cite this article as: {author}, "{title}," in <em>{sitename}</em>, {publication_date}, {permalink}, {shortlink}.','cite') ));2. I also included it in the functions like Miquel (see {shortlink}) :
// Admin page function wpcp_admin() { ?> <?php wpcp_setting_update_check(); ?> <form method="post" action="options.php"> <?php settings_fields('wpcp_setting'); ?> <?php global $wpcp_setting; ?> <div class="wpcp-admin"> <h2><?php _e('Cite Settings', 'cite') ?></h2> <p><?php _e('Help readers know how to cite your article correctly. Enter the reference text you wish to appear in the cite box using the editor below. Add the cite box to any page/post using shortcode', 'cite') ?> <code>[cite]</code></p> <p><textarea cols="80" rows="5" name="wpcp_setting[setting]" id="wpcp_setting[setting]" class="wpcp-textarea"><?php echo $wpcp_setting[setting]; ?></textarea></p> <p class="wpcp-templates-info"><span><?php _e('Available templates tags:', 'cite') ?></span><br> {author} - <?php _e('the post/page author','cite') ?><br> {title} - <?php _e('the title of your post/page', 'cite') ?><br> {sitename} - <?php _e('your site name taken from Settings > General', 'cite') ?><br> {publication_date} - <?php _e('date the page/post was published', 'cite') ?><br> {permalink} - <?php _e('the permalink of the page/post being accessed', 'cite') ?><br> {shortlink} - <?php _e('the shortlink of the page/post being accessed', 'cite') ?><br> {date} - <?php _e('the current date, if "date accessed" is desired', 'cite') ?><br> <?php _e('Also, you may insert words, HTML tags, and punctuation.', 'cite') ?><br><br> <b><?php _e('Samples', 'cite') ?></b> (<?php _e('similar to', 'cite') ?> <a href="http://www.chicagomanualofstyle.org/tools_citationguide.html" target="_blank"><?php _e('Chicago-style notes', 'cite') ?></a>):<br> <?php _e('Blog post:', 'cite') ?> {author}, "{title}," {sitename}, {publication_date}, {permalink}.<br> <?php _e('Book chapter:', 'cite') ?> {author}, "{title}," in {sitename}, ed. Jack Dougherty (Ann Arbor: Michigan Publishing, 2014), {permalink}.</p> <input type="hidden" name="wpcp_setting[update]" value="<?php _e('UPDATED', 'cite') ?>" /> <input type="submit" class="button-primary" value="<?php _e('Save Changes', 'cite') ?>" /> </form> </div> <?php }and most importantly in
3. Registering shortcode as
'<a href="' . get_bloginfo('url')."/?p=". (get_the_ID()) . '">' . get_bloginfo('url')."/?p=".(get_the_ID()) . '</a>'// Registering shortcode [cite] add_shortcode('cite', 'cite_shortcode'); function cite_shortcode() { global $wpcp_setting; // Getting admin preferred date format for current date if(!function_exists('displayTodaysDate')){ function displayTodaysDate() { return date_i18n(get_option('date_format')); } } $find_string = array('{author}','{sitename}', '{title}', '{date}', '{publication_date}', '{permalink}', '{shortlink}'); $replace_string = array(get_the_author(), get_bloginfo('name'), get_the_title(), displayTodaysDate(), get_the_date(), '<a href="' . get_permalink() . '">' . get_permalink() . '</a>', '<a href="' . get_bloginfo('url')."/?p=". (get_the_ID()) . '">' . get_bloginfo('url')."/?p=".(get_the_ID()) . '</a>'); $edited_setting = str_replace($find_string, $replace_string, $wpcp_setting[setting]); return '<div class="wpcp">' . $edited_setting . '</div>'; }
Viewing 1 replies (of 1 total)