function thirstyAdminOptions() { if (!current_user_can('manage_options')) { wp_die(__('You do not have suffifient permissions to access this page.', 'thirstyaffiliates')); } $thirstyOptions = get_option('thirstyOptions'); $linksRebuilt = false; if ($thirstyOptions['rebuildlinks'] == 'true') { $thirstyOptions['rebuildlinks'] = 'false'; update_option('thirstyOptions', $thirstyOptions); $thirstyOptions = get_option('thirstyOptions'); thirstyResaveAllLinks(); flush_rewrite_rules(); $linksRebuilt = true; } // Sanity check on link prefix if (empty($thirstyOptions['linkprefix'])) { $thirstyOptions['linkprefix'] = 'recommends'; update_option('thirstyOptions', $thirstyOptions); } $redirectTypes = thirstyGetRedirectTypes(); // Sanity check on link redirect type if (empty($thirstyOptions['linkredirecttype'])) { $thirstyOptions['linkredirecttype'] = '301'; update_option('thirstyOptions', $thirstyOptions); } $thirstyOptions['nofollow'] = isset($thirstyOptions['nofollow']) ? 'checked="checked"' : ''; $thirstyOptions['newwindow'] = isset($thirstyOptions['newwindow']) ? 'checked="checked"' : ''; $thirstyOptions['showcatinslug'] = isset($thirstyOptions['showcatinslug']) ? 'checked="checked"' : ''; $thirstyOptions['disablecatautoselect'] = isset($thirstyOptions['disablecatautoselect']) ? 'checked="checked"' : ''; $thirstyOptions['legacyuploader'] = isset($thirstyOptions['legacyuploader']) ? 'checked="checked"' : ''; $thirstyOptions['disabletitleattribute'] = isset($thirstyOptions['disabletitleattribute']) ? 'checked="checked"' : ''; $thirstyOptions['disablethirstylinkclass'] = isset($thirstyOptions['disablethirstylinkclass']) ? 'checked="checked"' : ''; $thirstyOptions['disableslugshortening'] = isset($thirstyOptions['disableslugshortening']) ? 'checked="checked"' : ''; $thirstyOptions['disablevisualeditorbuttons'] = isset($thirstyOptions['disablevisualeditorbuttons']) ? 'checked="checked"' : ''; $thirstyOptions['disabletexteditorbuttons'] = isset($thirstyOptions['disabletexteditorbuttons']) ? 'checked="checked"' : ''; echo '<script type="text/javascript">var thirstyPluginDir = "' . plugins_url('thirstyaffiliates/') . '"; var thirstyJSEnable = true; </script>'; echo '<div class="wrap">'; echo '<img id="thirstylogo" src="' . plugins_url('thirstyaffiliates/images/thirstylogo.png') . '" alt="ThirstyAffiliates" />'; echo '<form id="thirstySettingsForm" method="post" action="options.php">'; wp_nonce_field('update-options'); settings_fields('thirstyOptions'); if (!empty($_GET['settings-updated'])) { echo '<div id="message" class="updated below-h2"><p>' . __('Settings updated.', 'thirstyaffiliates') . '</p>' . ($linksRebuilt ? '<p>' . __('Links rebuilt.', 'thirstyaffiliates') . '</p>' : '') . '</div>'; } echo ' <table class="thirstyTable form-table" cellspacing="0" cellpadding="0"> <tr><td><h3 style="margin-top: 0;">' . __('General Settings', 'thirstyaffiliates') . '</h3></td></tr> <tr> <th> <label for="thirstyOptions[linkprefix]">' . __('Link Prefix:', 'thirstyaffiliates') . '</label> </th> <td> <select id="thirstyOptionsLinkPrefix" name="thirstyOptions[linkprefix]"> <option value="' . __('custom', 'thirstyaffiliates') . '"' . (!empty($thirstyOptions['linkprefix']) && $thirstyOptions['linkprefix'] == __('custom', 'thirstyaffiliates') ? __(' selected', 'thirstyaffiliates') : '') . '>-- ' . __('Custom', 'thirstyaffiliates') . ' --</option>'; thirstyGenerateSelectOptions(array("recommends", "link", "go", "review", "product", "suggests", "follow", "endorses", "proceed", "fly", "goto", "get", "find", "act", "click", "move", "offer", "run"), true); echo '</select><br /> <input type="text" id="thirstyCustomLinkPrefix" value="' . (isset($thirstyOptions['linkprefixcustom']) ? $thirstyOptions['linkprefixcustom'] : '') . '" name="thirstyOptions[linkprefixcustom]" />'; if (isset($thirstyOptions['linkprefix']) && $thirstyOptions['linkprefix'] == 'custom') { echo '<script type="text/javascript"> jQuery("#thirstyCustomLinkPrefix").css("display", "block"); jQuery("#thirstyCustomLinkPrefix").show(); </script>'; } echo '</td> <td> <span class="description">' . __('The prefix that comes before your cloaked link\'s slug.<br />eg. ', 'thirstyaffiliates') . trailingslashit(get_bloginfo('url')) . '<span style="font-weight: bold;">' . thirstyGetCurrentSlug() . '</span>/your-affiliate-link-name</span> <br /><span class="description"><b>' . __('Warning:', 'thirstyaffiliates') . '</b> ' . __('Changing this setting after you\'ve used links in a post could break those links. Be careful!', 'thirstyaffiliates') . '</span> </td> </tr> <tr> <th> <label for="thirstyOptions[showcatinslug]">' . __('Show Link Category in URL?', 'thirstyaffiliates') . '</label> <td> <input type="checkbox" name="thirstyOptions[showcatinslug]" id="thirstyOptionsShowCatInSlug" ' . $thirstyOptions['showcatinslug'] . ' /> </td> <td> <span class="description">' . __('Show the selected category in the url. eg. ', 'thirstyaffiliates') . trailingslashit(get_bloginfo('url')) . '' . thirstyGetCurrentSlug() . '/<span style="font-weight: bold;">link-category</span>/your-affiliate-link-name</span></span> <br /><span class="description"><b>' . __('Warning:', 'thirstyaffiliates') . '</b> ' . __('Changing this setting after you\'ve used links in a post could break those links. Be careful!', 'thirstyaffiliates') . '</span> </td> </tr> <tr> <th> <label for="thirstyOptions[disablecatautoselect]">' . __('Disable "uncategorized" category on save?', 'thirstyaffiliates') . '</label> <td> <input type="checkbox" name="thirstyOptions[disablecatautoselect]" id="thirstyOptionsDisableCatAutoSelect" ' . $thirstyOptions['disablecatautoselect'] . ' /> </td> <td> <span class="description">' . __('If the "Show the selected category in the url" option above is selected, by default ThirstyAffiliates will add an "uncategorized" category to apply to non-categorised links during save. If you disable this, it allows you to have some links with categories in the URL and some without.', 'thirstyaffiliates') . '</span> </td> </tr> <tr> <th> <label for="thirstyOptions[linkredirecttype]">' . __('Link Redirect Type:', 'thirstyaffiliates') . '</label> <td>'; foreach ($redirectTypes as $redirectTypeCode => $redirectTypeDesc) { $linkTypeSelected = false; if (strcasecmp($thirstyOptions['linkredirecttype'], $redirectTypeCode) == 0) { $linkTypeSelected = true; } echo '<input type="radio" name="thirstyOptions[linkredirecttype]" id="thirstyOptionsLinkRedirectType' . $redirectTypeCode . '" ' . ($linkTypeSelected ? 'checked="checked" ' : '') . 'value="' . $redirectTypeCode . '" /> <label for="thirstyOptionsLinkRedirectType' . $redirectTypeCode . '">' . $redirectTypeDesc . '</label><br />'; } echo ' </td> <td> <span class="description">' . __('This is the type of redirect ThirstyAffiliates will use to redirect the user to your affiliate link.', 'thirstyaffiliates') . '</span> </td> </tr> <tr> <th> <label for="thirstyOptions[nofollow]">' . __('Use no follow on links?', 'thirstyaffiliates') . '</label> <td> <input type="checkbox" name="thirstyOptions[nofollow]" id="thirstyOptionsNofollow" ' . $thirstyOptions['nofollow'] . ' /> </td> <td> <span class="description">' . __('Add the nofollow attribute to links so search engines don\'t index them', 'thirstyaffiliates') . '</span> </td> </tr> <tr> <th> <label for="thirstyOptions[newwindow]">' . __('Open links in new window?', 'thirstyaffiliates') . '</label> <td> <input type="checkbox" name="thirstyOptions[newwindow]" id="thirstyOptionsNewwindow" ' . $thirstyOptions['newwindow'] . ' /> </td> <td> <span class="description">' . __('Force the user to open links in a new window or tab', 'thirstyaffiliates') . '</span> </td> </tr> <tr> <th> <label for="thirstyOptions[legacyuploader]">' . __('Revert to legacy image uploader?', 'thirstyaffiliates') . '</label> <td> <input type="checkbox" name="thirstyOptions[legacyuploader]" id="thirstyOptionsLegacyUploader" ' . $thirstyOptions['legacyuploader'] . ' /> </td> <td> <span class="description">' . __('Disable the new media uploader in favour of the old style uploader', 'thirstyaffiliates') . '</span> </td> </tr> <tr> <th> <label for="thirstyOptions[disabletitleattribute]">' . __('Disable title attribute output on link insertion?', 'thirstyaffiliates') . '</label> <td> <input type="checkbox" name="thirstyOptions[disabletitleattribute]" id="thirstyOptionsDisableTitleAttribute" ' . $thirstyOptions['disabletitleattribute'] . ' /> </td> <td> <span class="description">' . __('Links are automatically output with a title html attribute (by default this shows the text that you have linked), this option lets you disable the output of the title attribute on your links.', 'thirstyaffiliates') . '</span> </td> </tr> <tr> <th> <label for="thirstyOptions[disablethirstylinkclass]">' . __('Disable automatic output of ThirstyAffiliates CSS classes?', 'thirstyaffiliates') . '</label> <td> <input type="checkbox" name="thirstyOptions[disablethirstylinkclass]" id="thirstyOptionsDisableThirstylinkClass" ' . $thirstyOptions['disablethirstylinkclass'] . ' /> </td> <td> <span class="description">' . __('To help with styling your affiliate links a CSS class called "thirstylink" is added to the link and a CSS class called "thirstylinkimg" is added to images (when inserting image affiliate links), this option disables the addition of both of these CSS classes.', 'thirstyaffiliates') . '</span> </td> </tr> <tr> <th> <label for="thirstyOptions[disableslugshortening]">' . __('Disable slug shortening?', 'thirstyaffiliates') . '</label> <td> <input type="checkbox" name="thirstyOptions[disableslugshortening]" id="thirstyOptionsDisableSlugShortening" ' . $thirstyOptions['disableslugshortening'] . ' /> </td> <td> <span class="description">' . __('By default, ThirstyAffiliates removes superfluous words from your cloaked link URLs, this option turns that feature off.', 'thirstyaffiliates') . '</span> </td> </tr> <tr> <th> <label for="thirstyOptions[disablevisualeditorbuttons]">' . __('Disable buttons on the Visual editor?', 'thirstyaffiliates') . '</label> <td> <input type="checkbox" name="thirstyOptions[disablevisualeditorbuttons]" id="thirstyOptionsDisableVisualEditorButtons" ' . $thirstyOptions['disablevisualeditorbuttons'] . ' /> </td> <td> <span class="description">' . __('Hide the ThirstyAffiliates buttons on the Visual editor.', 'thirstyaffiliates') . '</span> </td> </tr> <tr> <th> <label for="thirstyOptions[disabletexteditorbuttons]">' . __('Disable buttons on the Text/Quicktags editor?', 'thirstyaffiliates') . '</label> <td> <input type="checkbox" name="thirstyOptions[disabletexteditorbuttons]" id="thirstyOptionsDisableTextEditorButtons" ' . $thirstyOptions['disabletexteditorbuttons'] . ' /> </td> <td> <span class="description">' . __('Hide the ThirstyAffiliates buttons on the Text editor.', 'thirstyaffiliates') . '</span> </td> </tr> <tr> <th> <label for="thirstyOptions[additionalreltags]">' . __('Additional rel attribute tags to add during link insertion: ', 'thirstyaffiliates') . '</label> <td> <input type="text" name="thirstyOptions[additionalreltags]" id="thirstyOptionsAdditionalRelTags" value="' . $thirstyOptions['additionalreltags'] . '" /> </td> <td> <span class="description">' . __('Allows you to add extra tags into the rel= attribute when links are inserted.', 'thirstyaffiliates') . '</span> </td> </tr>'; do_action('thirstyAffiliatesAfterMainSettings'); echo ' </table> <input type="hidden" name="thirstyOptions[rebuildlinks]" id="thirstyHiddenRebuildFlag" value="false" /> <input type="hidden" name="page_options" value="thirstyOptions" /> <p class="submit"> <input type="submit" class="button-primary" value="' . __('Save All Changes', 'thirstyaffiliates') . '" /> <input type="submit" id="thirstyForceLinkRebuild" class="button-secondary" value="' . __('Save & Force Link Rebuild') . '" /> </p> </form> <div class="thirstyWhiteBox"> <h3>' . __('Plugin Information', 'thirstyaffiliates') . '</h3>' . 'ThirstyAffiliates Version: ' . THIRSTY_VERSION . '<br />'; do_action('thirstyAffiliatesPluginInformation'); echo '</div><!-- /.thirstyWhiteBox -->'; do_action('thirstyAffiliatesAfterPluginInformation'); echo ' <div class="thirstyWhiteBox"> <h3>Join The Community</h3> <ul id="thirstyCommunityLinks"><li><a href="http://thirstyaffiliates.com">' . __('Visit Our Website', 'thirstyaffiliates') . '</a></li> <li><a href="' . admin_url('edit.php?post_type=thirstylink&page=thirsty-addons') . '">' . __('Browse ThirstyAffiliates Add-ons', 'thirstyaffiliates') . '</a></li> <li><a href="http://thirstyaffiliates.com/affiliates">' . __('Join Our Affiliate Program', 'thirstyaffiliates') . '</a> ' . __('(up to 50% commissions)', 'thirstyaffiliates') . '</li> <li><a href="http://facebook.com/thirstyaffiliates" style="margin-right: 10px;">' . __('Like us on Facebook', 'thirstyaffiliates') . '</a><iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2Fthirstyaffiliates&send=false&layout=button_count&width=450&show_faces=false&font=arial&colorscheme=light&action=like&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px; vertical-align: bottom;" allowTransparency="true"></iframe></li> <li><a href="http://twitter.com/thirstyaff" style="margin-right: 10px;">' . __('Follow us on Twitter', 'thirstyaffiliates') . '</a> <a href="https://twitter.com/thirstyaff" class="twitter-follow-button" data-show-count="true" style="vertical-align: bottom;">Follow @thirstyaff</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?"http":"https";if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document, "script", "twitter-wjs");</script></li> </ul> </div><!-- /.thirstyWhiteBox --> </div><!-- /.wrap -->'; // Provide debug output for diagnostics and support use if (isset($_GET['debug'])) { if ($_GET['debug'] == 'true') { $thirstyOptions = get_option('thirstyOptions'); // re-retrieve options in case any of the filters/actions messed with it echo '<pre>' . __('DEBUG: ', 'thirstyaffiliates') . print_r($thirstyOptions, true) . '</pre>'; } } }
function thirstyCatLinks($post_link, $post) { $thirstyOptions = get_option('thirstyOptions'); $slug = thirstyGetCurrentSlug(); if (is_wp_error($post) || empty($post) || !empty($post) && $post->post_type != 'thirstylink' || empty($post->post_name)) { return $post_link; } // Get the link category: $terms = get_the_terms($post->ID, 'thirstylink-category'); if (empty($thirstyOptions['showcatinslug']) || $thirstyOptions['showcatinslug'] != 'on' || is_wp_error($terms) || !$terms) { $linkCat = ''; } else { $linkCatObj = array_pop($terms); $linkCat = $linkCatObj->slug . '/'; } return home_url(user_trailingslashit("{$slug}/{$linkCat}{$post->post_name}")); }