/** * Includes activated templates' settings.php files. * * @remark This is called from the initial loader class. */ public function loadSettingsOfActiveTemplates() { if (!is_admin()) { return; } if (!FetchTweets_PluginUtility::isInPluginAdminPage()) { return; } $this->_loadFileOfActiveTemplatesByFileName('settings.php'); }
protected function echoFormElements($aInstance, $aIDs, $aNames) { ?> <label for="<?php echo $aIDs['title']; ?> "> <?php _e('Title', 'fetch-tweets'); ?> : </label> <p> <input type="text" name="<?php echo $aNames['title']; ?> " id="<?php echo $aIDs['title']; ?> " value="<?php echo $aInstance['title']; ?> "/> </p> <label for="<?php echo $aIDs['selected_ids']; ?> "> <?php _e('Select Rules', 'fetch-tweets'); ?> : </label> <br /> <select name="<?php echo $aNames['selected_ids']; ?> []" id="<?php echo $aIDs['selected_ids']; ?> " multiple style="min-width: 220px;"> <?php $oQuery = new WP_Query(array('post_status' => 'publish', 'post_type' => FetchTweets_Commons::PostTypeSlug, 'posts_per_page' => -1)); foreach ($oQuery->posts as $oPost) { echo "<option value='{$oPost->ID}' " . (in_array($oPost->ID, $aInstance['selected_ids']) ? 'selected="Selected"' : '') . ">" . $oPost->post_title . "</option>"; } ?> </select> <p class="description" style="margin-top: 10px;"> <?php _e('Hold down the Ctrl (windows) / Command (Mac) key to select multiple items.', 'fetch-tweets'); ?> </p> <label for="<?php echo $aIDs['count']; ?> "> <?php _e('The maximum number of tweets to show', 'fetch-tweets'); ?> : </label> <br /> <p> <input type="number" id="<?php echo $aIDs['count']; ?> " name="<?php echo $aNames['count']; ?> " min="1" value="<?php echo $aInstance['count']; ?> "/> </p> <p class="description" style="margin-top: 10px; padding-bottom: 5px;"> <?php _e('Default', 'fetch-tweets'); ?> : 20 </p> <p> <label for="<?php echo $aIDs['twitter_media']; ?> "> <input type="hidden" name="<?php echo $aNames['twitter_media']; ?> " value=0 /> <input type="checkbox" id="<?php echo $aIDs['twitter_media']; ?> " name="<?php echo $aNames['twitter_media']; ?> " value="1" <?php echo $aInstance['twitter_media'] ? 'checked="Checked"' : ''; ?> /> <?php _e('Show Twitter media.', 'fetch-tweets'); ?> </label> </p> <p> <label for="<?php echo $aIDs['external_media']; ?> "> <input type="hidden" name="<?php echo $aNames['external_media']; ?> " value=0 /> <input type="checkbox" id="<?php echo $aIDs['external_media']; ?> " name="<?php echo $aNames['external_media']; ?> " value="1" <?php echo $aInstance['external_media'] ? 'checked="Checked"' : ''; ?> /> <?php _e('Show external media.', 'fetch-tweets'); ?> </label> </p> <p> <label for="<?php echo $aIDs['template']; ?> "> <?php _e('Select a Template', 'fetch-tweets'); ?> : </label> <br /> <select name="<?php echo $aNames['template']; ?> " id="<?php echo $aIDs['template']; ?> " > <?php foreach (FetchTweets_PluginUtility::getTemplateArrayForSelectLabel() as $sTemplateSlug => $sTemplateName) { echo "<option value='{$sTemplateSlug}' " . ($aInstance['template'] == $sTemplateSlug ? 'selected="Selected"' : '') . ">" . $sTemplateName . "</option>"; } ?> </select> </p> <label for="<?php echo $aIDs['avatar_size']; ?> "> <?php _e('The profile image size in pixel.', 'fetch-tweets'); ?> : </label> <p> <input type="number" id="<?php echo $aIDs['avatar_size']; ?> " name="<?php echo $aNames['avatar_size']; ?> " min="0" value="<?php echo $aInstance['avatar_size']; ?> "/> </p> <p class="description" style="margin-top: 10px;"> <?php _e('Set 0 for no avatar.', 'fetch-tweets'); ?> <?php _e('Default', 'fetch-tweets'); ?> : 48 </p> <label for="<?php echo $aIDs['width']; ?> "> <?php _e('The width of the output.', 'fetch-tweets'); ?> : </label> <p> <input type="number" id="<?php echo $aIDs['width']; ?> " name="<?php echo $aNames['width']; ?> " min="0" value="<?php echo $aInstance['width']; ?> "/> <select name="<?php echo $aNames['width_unit']; ?> " id="<?php echo $aIDs['width_unit']; ?> " > <?php foreach (array('px' => 'px', '%' => '%', 'em' => 'em') as $sUnitKey => $sUnitName) { echo "<option value='{$sUnitKey}' " . ($aInstance['width_unit'] == $sUnitKey ? 'selected="Selected"' : '') . ">" . $sUnitName . "</option>"; } ?> </select> </p> <p class="description" style="margin-top: 10px;"> <?php _e('Set 0 for no limit.', 'fetch-tweets'); ?> <?php _e('Default', 'fetch-tweets'); ?> : <code>100 %</code>. </p> <label for="<?php echo $aIDs['height']; ?> "> <?php _e('The height of the output.', 'fetch-tweets'); ?> : </label> <p> <input type="number" id="<?php echo $aIDs['height']; ?> " name="<?php echo $aNames['height']; ?> " min="0" value="<?php echo $aInstance['height']; ?> "/> <select name="<?php echo $aNames['height_unit']; ?> " id="<?php echo $aIDs['height_unit']; ?> " > <?php foreach (array('px' => 'px', '%' => '%', 'em' => 'em') as $sUnitKey => $sUnitName) { echo "<option value='{$sUnitKey}' " . ($aInstance['height_unit'] == $sUnitKey ? 'selected="Selected"' : '') . ">" . $sUnitName . "</option>"; } ?> </select> </p> <p class="description" style="margin-top: 10px;"> <?php _e('Set 0 for no limit.', 'fetch-tweets'); ?> <?php _e('Default', 'fetch-tweets'); ?> : <code>400 px</code>. </p> <?php }
protected function echoFormElements($aInstance, $aIDs, $aNames) { ?> <label for="<?php echo $aIDs['title']; ?> "> <?php _e('Title', 'fetch-tweets'); ?> : </label> <p> <input type="text" name="<?php echo $aNames['title']; ?> " id="<?php echo $aIDs['title']; ?> " value="<?php echo $aInstance['title']; ?> "/> </p> <label for="<?php echo $aIDs['selected_tag_slugs']; ?> "> <?php _e('Select Tags', 'fetch-tweets'); ?> : </label> <br /> <select name="<?php echo $aNames['selected_tag_slugs']; ?> []" id="<?php echo $aIDs['selected_tag_slugs']; ?> " multiple style="min-width: 220px;"> <?php foreach ($this->getTagSlugArrays() as $sTagSlug => $sTagName) { echo "<option value='{$sTagSlug}' " . (in_array($sTagSlug, $aInstance['selected_tag_slugs']) ? 'selected="Selected"' : '') . ">" . $sTagName . "</option>"; } ?> </select> <p class="description" style="margin-top: 10px;"> <?php _e('Hold down the Ctrl (windows) / Command (Mac) key to select multiple items.', 'fetch-tweets'); ?> </p> <p> <?php _e('Apply the rule sets that have:', 'fetch-tweets'); ?> <span style="display: block; margin: 8px;"> <input id="<?php echo $aIDs['operator']; ?> [0]" type="radio" name="<?php echo $aNames['operator']; ?> " value="AND" <?php echo $aInstance['operator'] == 'AND' ? "Checked" : ""; ?> /> <label for="<?php echo $aIDs['operator']; ?> [0]"> <?php _e('All', 'fetch-tweets'); ?> </label> <input id="<?php echo $aIDs['operator']; ?> [1]" type="radio" name="<?php echo $aNames['operator']; ?> " value="IN" <?php echo $aInstance['operator'] == 'IN' ? "Checked" : ""; ?> /> <label for="<?php echo $aIDs['operator']; ?> [1]"> <?php _e('Any', 'fetch-tweets'); ?> </label> <input id="<?php echo $aIDs['operator']; ?> [2]" type="radio" name="<?php echo $aNames['operator']; ?> " value="NOT IN" <?php echo $aInstance['operator'] == 'NOT IN' ? "Checked" : ""; ?> /> <label for="<?php echo $aIDs['operator']; ?> [2]"> <?php _e('None', 'fetch-tweets'); ?> </label> </span> <?php _e('of the selected tags.', 'fetch-tweets'); ?> </p> <label for="<?php echo $aIDs['count']; ?> "> <?php _e('The maximum number of tweets to show', 'fetch-tweets'); ?> : </label> <br /> <p> <input type="number" id="<?php echo $aIDs['count']; ?> " name="<?php echo $aNames['count']; ?> " min="1" value="<?php echo $aInstance['count']; ?> "/> </p> <p class="description" style="margin-top: 10px; padding-bottom: 5px;"> <?php _e('Default', 'fetch-tweets'); ?> : 20 </p> <p> <label for="<?php echo $aIDs['twitter_media']; ?> "> <input type="hidden" name="<?php echo $aNames['twitter_media']; ?> " value=0 /> <input type="checkbox" id="<?php echo $aIDs['twitter_media']; ?> " name="<?php echo $aNames['twitter_media']; ?> " value="1" <?php echo $aInstance['twitter_media'] ? 'checked="Checked"' : ''; ?> /> <?php _e('Show Twitter media.', 'fetch-tweets'); ?> </label> </p> <p> <label for="<?php echo esc_attr($aIDs['external_media']); ?> "> <input type="hidden" name="<?php echo esc_attr($aNames['external_media']); ?> " value=0 /> <input type="checkbox" id="<?php echo esc_attr($aIDs['external_media']); ?> " name="<?php echo esc_attr($aNames['external_media']); ?> " value="1" <?php echo esc_attr($aInstance['external_media']) ? 'checked="checked"' : ''; ?> /> <?php _e('Show external media.', 'fetch-tweets'); ?> </label> </p> <p> <label for="<?php echo esc_attr($aIDs['template']); ?> "> <?php _e('Select a Template', 'fetch-tweets'); ?> : </label> <br /> <select name="<?php echo esc_attr($aNames['template']); ?> " id="<?php echo esc_attr($aIDs['template']); ?> " > <?php foreach (FetchTweets_PluginUtility::getTemplateArrayForSelectLabel() as $_sTemplateSlug => $_sTemplateName) { echo "<option value='" . esc_attr($_sTemplateSlug) . "' " . ($aInstance['template'] == $_sTemplateSlug ? 'selected="selected"' : '') . ">" . $_sTemplateName . "</option>"; } ?> </select> </p> <label for="<?php echo esc_attr($aIDs['avatar_size']); ?> "> <?php _e('The profile image size in pixel.', 'fetch-tweets'); ?> : </label> <p> <input type="number" id="<?php echo esc_attr($aIDs['avatar_size']); ?> " name="<?php echo esc_attr($aNames['avatar_size']); ?> " min="0" value="<?php echo esc_attr($aInstance['avatar_size']); ?> " /> </p> <p class="description" style="margin-top: 10px;"> <?php _e('Set 0 for no avatar.', 'fetch-tweets'); ?> <?php _e('Default', 'fetch-tweets'); ?> : 48 </p> <label for="<?php echo esc_attr($aIDs['width']); ?> "> <?php _e('The width of the output.', 'fetch-tweets'); ?> : </label> <p> <input type="number" id="<?php echo esc_attr($aIDs['width']); ?> " name="<?php echo esc_attr($aNames['width']); ?> " min="0" value="<?php echo esc_attr($aInstance['width']); ?> "/> <select name="<?php echo esc_attr($aNames['width_unit']); ?> " id="<?php echo esc_attr($aIDs['width_unit']); ?> " > <?php foreach (array('px' => 'px', '%' => '%', 'em' => 'em') as $sUnitKey => $sUnitName) { echo "<option value='" . esc_attr($sUnitKey) . "' " . ($aInstance['width_unit'] == $sUnitKey ? 'selected="selected"' : '') . ">" . $sUnitName . "</option>"; } ?> </select> </p> <p class="description" style="margin-top: 10px;"> <?php _e('Set 0 for no limit.', 'fetch-tweets'); ?> <?php _e('Default', 'fetch-tweets'); ?> : <code>100 %</code>. </p> <label for="<?php echo esc_attr($aIDs['height']); ?> "> <?php _e('The height of the output.', 'fetch-tweets'); ?> : </label> <p> <input type="number" id="<?php echo esc_attr($aIDs['height']); ?> " name="<?php echo esc_attr($aNames['height']); ?> " min="0" value="<?php echo esc_attr($aInstance['height']); ?> "/> <select name="<?php echo esc_attr($aNames['height_unit']); ?> " id="<?php echo esc_attr($aIDs['height_unit']); ?> " > <?php foreach (array('px' => 'px', '%' => '%', 'em' => 'em') as $sUnitKey => $sUnitName) { echo "<option value='" . esc_attr($sUnitKey) . "' " . ($aInstance['height_unit'] == $sUnitKey ? 'selected="selected"' : '') . ">" . $sUnitName . "</option>"; } ?> </select> </p> <p class="description" style="margin-top: 10px;"> <?php _e('Set 0 for no limit.', 'fetch-tweets'); ?> <?php _e('Default', 'fetch-tweets'); ?> : <code>400 px</code>. </p> <?php }
/** * Adds form fields for the options to fetch tweets by keyword search to the meta box. * * @since 1.0.0 */ public function setUp() { $this->addSettingFields(array('field_id' => 'tweet_type', 'type' => 'hidden', 'value' => 'search', 'hidden' => true), array('field_id' => 'search_keyword', 'title' => __('Search Keyword', 'fetch-tweets'), 'description' => sprintf(__('The keyword to search. For a complex combination of terms and operators, refer to the <strong>Search Operators</strong> section of <a href="%1$s" target="_blank">Using the Twitter Search API</a>.', 'fetch-tweets'), 'https://dev.twitter.com/docs/using-search') . ' e.g. <code>love OR hate</code>, <code>#wordpress</code>', 'type' => 'text', 'attributes' => array('size' => 40)), array('field_id' => 'item_count', 'title' => __('Item Count', 'fetch-tweets'), 'description' => __('Set how many items should be fetched.', 'fetch-tweets') . ' ' . __('Max', 'fetch-tweets') . ': 100 ' . __('Default', 'fetch-tweets') . ': 20', 'type' => 'number', 'default' => 20, 'attributes' => array('max' => 100)), array('field_id' => 'language', 'title' => __('Language ', 'fetch-tweets'), 'type' => 'select', 'label' => FetchTweets_PluginUtility::getLanguageListForSearchAPI(), 'default' => 'none'), array('field_id' => 'result_type', 'title' => __('Result Type', 'fetch-tweets'), 'type' => 'radio', 'label' => array('mixed' => 'mixed' . ' - ' . __('includes both popular and real time results in the response.', 'fetch-tweets'), 'recent' => 'recent' . ' - ' . __('returns only the most recent results in the response.', 'fetch-tweets'), 'popular' => 'popular' . ' - ' . __('return only the most popular results in the response.', 'fetch-tweets')), 'default' => 'mixed'), array('field_id' => 'until', 'title' => __('Date Until', 'fetch-tweets') . " <span class='description'>(" . __('optional', 'fetch-tweets') . ")</span>", 'description' => __('Returns tweets generated before the given date. Set blank not to specify any date.', 'fetch-tweets') . ' ' . __('Format', 'fetch-tweets') . ': ' . '<code>yy-mm-dd</code>', 'type' => 'date', 'date_format' => 'yy-mm-dd'), array('field_id' => 'geocentric_coordinate', 'title' => __('Geometric Coordinate', 'fetch-tweets') . " <span class='description'>(" . __('optional', 'fetch-tweets') . ")</span>", 'description' => __('Restricts tweets to users located within a given radius of the given latitude/longitude. Leave them empty not to set any.', 'fetch-tweets'), 'type' => 'geometry'), array('field_id' => 'geocentric_radius', 'title' => __('Geometric Radius', 'fetch-tweets') . " <span class='description'>(" . __('optional', 'fetch-tweets') . ")</span>", 'type' => 'size', 'default' => array('size' => '', 'unit' => 'mi'), 'units' => array('mi' => __('miles', 'fetch-tweets'), 'km' => __('kilometers', 'fetch-tweets')), 'description' => __('Leave this empty not to set any. In order to perform the geometric search, this option and the above coordinate must be specified.', 'fetch-tweets')), array()); }
/** * Loads all necessary plugin components. * * @remark A callback of the 'plugins_loaded' action hook. */ public function _replyToLoadPluginComponents() { do_action('fetch_tweets_action_before_loading_plugin'); // 2. Option Object - the instantiation will handle the initial set-up FetchTweets_Option::getInstance(); // 3. Load active templates - this must be done after loading the option class as it stores active templates. new FetchTweets_TemplatesLoader(); // 4. Admin pages if ($this->_bIsAdmin) { new FetchTweets_AdminPage(FetchTweets_Commons::$sAdminKey, $this->_sFilePath); new FetchTweets_AdminPage_Contact('', $this->_sFilePath); } // 5. Post Type - no need to check is_admin() because posts of custom post type can be accessed from the front-end. new FetchTweets_PostType(FetchTweets_Commons::PostTypeSlug, null, $this->_sFilePath); // post type slug // 6. Meta-boxes if ($this->_bIsAdmin) { $this->_registerMetaBoxes(); } // 7. Shortcode - enables the shortcode. e.g. [fetch_tweets id="143"] new FetchTweets_Shortcode('fetch_tweets'); // 8. Widgets add_action('widgets_init', 'FetchTweets_WidgetByID::registerWidget'); add_action('widgets_init', 'FetchTweets_WidgetByTag::registerWidget'); // 9. Events - handles background processes. new FetchTweets_Event(); // 10. MISC if (FetchTweets_PluginUtility::isInPluginAdminPage()) { $GLOBALS['oFetchTweetsUserAds'] = isset($GLOBALS['oFetchTweetsUserAds']) ? $GLOBALS['oFetchTweetsUserAds'] : new FetchTweets_UserAds(); } // 11. WordPress version backward compatibility. $this->_defineConstantesForBackwardCompatibility(); do_action('fetch_tweets_action_after_loading_plugin'); }
public function setUp() { $_oTemplate = new FetchTweets_Template(); // passing an empty value will make the object default template. $this->addSettingFields(array('field_id' => 'fetch_tweets_template', 'title' => __('Select Template', 'fetch-tweets'), 'description' => __('Set the default template for this rule. If a template is specified in a widget, the shortcode, or the function, this setting will be overridden.', 'fetch-tweets'), 'label' => $arr = FetchTweets_PluginUtility::getTemplateArrayForSelectLabel(), 'type' => 'select', 'default' => $_oTemplate->getSlug(), 'show_title_column' => false), array()); }