custom-facebook-feed
Last commit date
css
13 years ago
img
13 years ago
README.txt
13 years ago
custom-facebook-feed-admin.php
13 years ago
custom-facebook-feed.php
13 years ago
gpl-2.0.txt
13 years ago
custom-facebook-feed-admin.php
167 lines
| 1 | <?php |
| 2 | function cff_menu() { |
| 3 | add_menu_page('Settings', 'Custom Facebook Feed', 'manage_options', 'cff-top', 'cff_settings_page'); |
| 4 | } |
| 5 | add_action('admin_menu', 'cff_menu'); |
| 6 | |
| 7 | //Create Settings page |
| 8 | function cff_settings_page() { |
| 9 | |
| 10 | //Declare variables for fields |
| 11 | $hidden_field_name = 'cff_submit_hidden'; |
| 12 | $access_token = 'cff_access_token'; |
| 13 | $page_id = 'cff_page_id'; |
| 14 | $num_show = 'cff_num_show'; |
| 15 | $cff_title_length = 'cff_title_length'; |
| 16 | $cff_body_length = 'cff_body_length'; |
| 17 | |
| 18 | // Read in existing option value from database |
| 19 | $access_token_val = get_option( $access_token ); |
| 20 | $page_id_val = get_option( $page_id ); |
| 21 | $num_show_val = get_option( $num_show ); |
| 22 | $cff_title_length_val = get_option( $cff_title_length ); |
| 23 | $cff_body_length_val = get_option( $cff_body_length ); |
| 24 | |
| 25 | // See if the user has posted us some information. If they did, this hidden field will be set to 'Y'. |
| 26 | if( isset($_POST[ $hidden_field_name ]) && $_POST[ $hidden_field_name ] == 'Y' ) { |
| 27 | // Read their posted value |
| 28 | $access_token_val = $_POST[ $access_token ]; |
| 29 | $page_id_val = $_POST[ $page_id ]; |
| 30 | $num_show_val = $_POST[ $num_show ]; |
| 31 | $cff_title_length_val = $_POST[ $cff_title_length ]; |
| 32 | $cff_body_length_val = $_POST[ $cff_body_length ]; |
| 33 | |
| 34 | // Save the posted value in the database |
| 35 | update_option( $access_token, $access_token_val ); |
| 36 | update_option( $page_id, $page_id_val ); |
| 37 | update_option( $num_show, $num_show_val ); |
| 38 | update_option( $cff_title_length, $cff_title_length_val ); |
| 39 | update_option( $cff_body_length, $cff_body_length_val ); |
| 40 | |
| 41 | // Put an settings updated message on the screen |
| 42 | ?> |
| 43 | <div class="updated"><p><strong><?php _e('Settings saved.', 'custom-facebook-feed' ); ?></strong></p></div> |
| 44 | |
| 45 | <?php } ?> |
| 46 | |
| 47 | <div class="wrap"> |
| 48 | |
| 49 | <h2><?php _e('Custom Facebook Feed'); ?></h2> |
| 50 | |
| 51 | <form name="form1" method="post" action=""> |
| 52 | |
| 53 | <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y"> |
| 54 | |
| 55 | |
| 56 | <h3><?php _e('Feed Settings'); ?></h3> |
| 57 | |
| 58 | |
| 59 | <table class="form-table"> |
| 60 | |
| 61 | <tbody> |
| 62 | |
| 63 | <tr valign="top"> |
| 64 | |
| 65 | <th scope="row"><?php _e('Access Token'); ?></th> |
| 66 | |
| 67 | <td> |
| 68 | |
| 69 | <input name="cff_access_token" type="text" value="<?php esc_attr_e( $access_token_val ); ?>" size="60" /> |
| 70 | |
| 71 | <a href="http://smashballoon.com/custom-facebook-feed/access-token/" target="_blank">How to get an Access Token</a> |
| 72 | |
| 73 | </td> |
| 74 | |
| 75 | </tr> |
| 76 | |
| 77 | <tr valign="top"> |
| 78 | |
| 79 | <th scope="row"><?php _e('Page ID'); ?></th> |
| 80 | |
| 81 | <td> |
| 82 | |
| 83 | <input name="cff_page_id" type="text" value="<?php esc_attr_e( $page_id_val ); ?>" size="60" /> |
| 84 | |
| 85 | <a href="http://smashballoon.com/custom-facebook-feed/faq/" target="_blank">What's my Page ID?</a> |
| 86 | |
| 87 | </td> |
| 88 | |
| 89 | </tr> |
| 90 | |
| 91 | <tr valign="top"> |
| 92 | |
| 93 | <th scope="row"><?php _e('Number of posts to display'); ?></th> |
| 94 | |
| 95 | <td> |
| 96 | |
| 97 | <input name="cff_num_show" type="text" value="<?php esc_attr_e( $num_show_val ); ?>" size="4" /> |
| 98 | |
| 99 | </td> |
| 100 | |
| 101 | </tr> |
| 102 | |
| 103 | </tbody> |
| 104 | |
| 105 | </table> |
| 106 | |
| 107 | <br /> |
| 108 | <h3><?php _e('Post Formatting'); ?></h3> |
| 109 | |
| 110 | |
| 111 | <table class="form-table"> |
| 112 | |
| 113 | <tbody> |
| 114 | |
| 115 | <tr valign="top"> |
| 116 | |
| 117 | <th scope="row"><?php _e('Maximum Post Title Length'); ?></th> |
| 118 | |
| 119 | <td> |
| 120 | |
| 121 | <input name="cff_title_length" type="text" value="<?php esc_attr_e( $cff_title_length_val ); ?>" size="4" /> <span>Characters.</span> <i style="color: #666; font-size: 11px; margin-left: 5px;">(Leave empty to set no maximum length)</i> |
| 122 | |
| 123 | </td> |
| 124 | |
| 125 | </tr> |
| 126 | |
| 127 | <tr valign="top"> |
| 128 | |
| 129 | <th scope="row"><?php _e('Maximum Post Body Text Length'); ?></th> |
| 130 | |
| 131 | <td> |
| 132 | |
| 133 | <input name="cff_body_length" type="text" value="<?php esc_attr_e( $cff_body_length_val ); ?>" size="4" /> <span>Characters.</span> <i style="color: #666; font-size: 11px; margin-left: 5px;">(Leave empty to set no maximum length)</i> |
| 134 | |
| 135 | </td> |
| 136 | |
| 137 | </tr> |
| 138 | |
| 139 | </tbody> |
| 140 | |
| 141 | </table> |
| 142 | |
| 143 | <?php submit_button(); ?> |
| 144 | |
| 145 | |
| 146 | </form> |
| 147 | |
| 148 | <hr /> |
| 149 | |
| 150 | <h4>Displaying your Feed</h4> |
| 151 | |
| 152 | <p>Copy and paste this shortcode directly into the page, post or widget where you'd like the feed to show up:</p> |
| 153 | |
| 154 | <input type="text" value="[custom-facebook-feed]" size="23" /> |
| 155 | |
| 156 | <p>You can override the settings above directly in the shortcode like so:</p> |
| 157 | |
| 158 | <p>[custom-facebook-feed <b>id=Your_Page_ID show=3 titlelength=100 bodylength=150</b>]</p> |
| 159 | |
| 160 | <br /><br /><a href="http://smashballoon.com/custom-facebook-feed/" target="_blank">Plugin Support</a> |
| 161 | |
| 162 | <br /><br /><br /> |
| 163 | <a href="http://smashballoon.com/custom-facebook-feed/" target="_blank"><img src="<?php echo plugins_url( 'img/pro.jpg' , __FILE__ ) ?>" /></a> |
| 164 | |
| 165 | <?php |
| 166 | } //End Settings_Page |
| 167 | ?> |