当前位置: 首页>>代码示例>>PHP>>正文


PHP Sharing_Service::new_service方法代码示例

本文整理汇总了PHP中Sharing_Service::new_service方法的典型用法代码示例。如果您正苦于以下问题:PHP Sharing_Service::new_service方法的具体用法?PHP Sharing_Service::new_service怎么用?PHP Sharing_Service::new_service使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sharing_Service的用法示例。


在下文中一共展示了Sharing_Service::new_service方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ajax_new_service

 public function ajax_new_service()
 {
     if (isset($_POST['_wpnonce']) && isset($_POST['sharing_name']) && isset($_POST['sharing_url']) && isset($_POST['sharing_icon']) && wp_verify_nonce($_POST['_wpnonce'], 'sharing-new_service')) {
         $sharer = new Sharing_Service();
         if ($service = $sharer->new_service($_POST['sharing_name'], $_POST['sharing_url'], $_POST['sharing_icon'])) {
             $this->output_service($service->get_id(), $service);
             echo '<!--->';
             $service->button_style = 'icon-text';
             $this->output_preview($service);
             die;
         }
     }
     // Fail
     die('1');
 }
开发者ID:jfitzsimmons,项目名称:hoseb.com,代码行数:15,代码来源:sharing.php

示例2: update_data


//.........这里部分代码省略.........
             case 'google':
             case 'bing':
             case 'pinterest':
             case 'yandex':
                 $grouped_options = $grouped_options_current = (array) get_option('verification_services_codes');
                 $grouped_options[$option] = $value;
                 // If option value was the same, consider it done.
                 $updated = $grouped_options_current != $grouped_options ? update_option('verification_services_codes', $grouped_options) : true;
                 break;
             case 'sharing_services':
                 if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
                     break;
                 }
                 $sharer = new Sharing_Service();
                 // If option value was the same, consider it done.
                 $updated = $value != $sharer->get_blog_services() ? $sharer->set_blog_services($value['visible'], $value['hidden']) : true;
                 break;
             case 'button_style':
             case 'sharing_label':
             case 'show':
                 if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
                     break;
                 }
                 $sharer = new Sharing_Service();
                 $grouped_options = $sharer->get_global_options();
                 $grouped_options[$option] = $value;
                 $updated = $sharer->set_global_options($grouped_options);
                 break;
             case 'custom':
                 if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
                     break;
                 }
                 $sharer = new Sharing_Service();
                 $updated = $sharer->new_service(stripslashes($value['sharing_name']), stripslashes($value['sharing_url']), stripslashes($value['sharing_icon']));
                 // Return new custom service
                 $response[$option] = $updated;
                 break;
             case 'sharing_delete_service':
                 if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
                     break;
                 }
                 $sharer = new Sharing_Service();
                 $updated = $sharer->delete_service($value);
                 break;
             case 'jetpack-twitter-cards-site-tag':
                 $value = trim(ltrim(strip_tags($value), '@'));
                 $updated = get_option($option) !== $value ? update_option($option, $value) : true;
                 break;
             case 'onpublish':
             case 'onupdate':
             case 'Bias Language':
             case 'Cliches':
             case 'Complex Expression':
             case 'Diacritical Marks':
             case 'Double Negative':
             case 'Hidden Verbs':
             case 'Jargon Language':
             case 'Passive voice':
             case 'Phrases to Avoid':
             case 'Redundant Expression':
             case 'guess_lang':
                 if (in_array($option, array('onpublish', 'onupdate'))) {
                     $atd_option = 'AtD_check_when';
                 } elseif ('guess_lang' == $option) {
                     $atd_option = 'AtD_guess_lang';
                     $option = 'true';
开发者ID:netmagik,项目名称:netmagik,代码行数:67,代码来源:class.jetpack-core-api-module-endpoints.php

示例3: callback

 public function callback($path = '', $blog_id = 0, $button_id = 0)
 {
     $new = $this->api->ends_with($path, '/new');
     $input = $this->input();
     // Validate request
     $blog_id = $this->api->switch_to_blog_and_validate_user($this->api->get_blog_id($blog_id));
     if (is_wp_error($blog_id)) {
         return $blog_id;
     }
     if (!current_user_can('manage_options')) {
         return new WP_Error('forbidden', 'You do not have the capability to manage sharing buttons for this site', 403);
     } else {
         if (!class_exists('Sharing_Service') || !class_exists('Sharing_Source') || method_exists('Jetpack', 'is_module_active') && !Jetpack::is_module_active('sharedaddy')) {
             return new WP_Error('missing_jetpack_module', 'The Sharing module must be activated in order to use this endpoint', 400);
         } else {
             if (!empty($input['visibility']) && !in_array($input['visibility'], WPCOM_JSON_API_Get_Sharing_Buttons_Endpoint::$all_visibilities)) {
                 return new WP_Error('invalid_visibility', sprintf('The visibility field must be one of the following values: %s', implode(', ', WPCOM_JSON_API_Get_Sharing_Buttons_Endpoint::$all_visibilities)), 400);
             } else {
                 if ($new && empty($input['URL'])) {
                     return new WP_Error('invalid_request', 'The URL field is required', 400);
                 } else {
                     if ($new && empty($input['icon'])) {
                         return new WP_Error('invalid_request', 'The icon field is required', 400);
                     }
                 }
             }
         }
     }
     // Assign default values
     $visibility = $input['visibility'];
     if (empty($visibility) || !isset($input['visibility']) && true === $input['enabled']) {
         $visibility = 'visible';
     }
     // Update or create button
     $ss = new Sharing_Service();
     $blog_services = $ss->get_blog_services();
     if ($new) {
         // Attempt to create new button
         $updated_service = $ss->new_service($input['name'], $input['URL'], $input['icon']);
         if (false !== $updated_service && (isset($input['enabled']) && true === $input['enabled'] || isset($input['visibility']))) {
             $blog_services[$visibility][(string) $updated_service->get_id()] = $updated_service;
             $ss->set_blog_services(array_keys($blog_services['visible']), array_keys($blog_services['hidden']));
         }
     } else {
         // Find existing button
         $all_buttons = $ss->get_all_services_blog();
         if (!array_key_exists($button_id, $all_buttons)) {
             // Button doesn't exist
             return new WP_Error('not_found', 'The specified sharing button was not found', 404);
         }
         $updated_service = $all_buttons[$button_id];
         $service_id = $updated_service->get_id();
         if (is_a($all_buttons[$button_id], 'Share_Custom')) {
             // Replace options for existing custom button
             $options = $updated_service->get_options();
             $name = isset($input['name']) ? $input['name'] : $options['name'];
             $url = isset($input['URL']) ? $input['URL'] : $options['url'];
             $icon = isset($input['icon']) ? $input['icon'] : $options['icon'];
             $updated_service = new Share_Custom($service_id, array('name' => $name, 'url' => $url, 'icon' => $icon));
             $ss->set_service($button_id, $updated_service);
         }
         // Update button visibility
         $visibility_changed = (isset($input['visibility']) || true === $input['enabled']) && !array_key_exists($service_id, $blog_services[$visibility]);
         $is_disabling = false === $input['enabled'];
         if ($visibility_changed || $is_disabling) {
             // Remove from all other visibilities
             foreach ($blog_services as $service_visibility => $services) {
                 if ($service_visibility !== $visibility || $is_disabling) {
                     unset($blog_services[$service_visibility][$service_id]);
                 }
             }
             if ($visibility_changed) {
                 $blog_services[$visibility][$service_id] = $updated_service;
             }
             $ss->set_blog_services(array_keys($blog_services['visible']), array_keys($blog_services['hidden']));
         }
     }
     if (false === $updated_service) {
         return new WP_Error('invalid_request', sprintf('The sharing button was not %s', $new ? 'created' : 'updated'), 400);
     } else {
         return WPCOM_JSON_API_Get_Sharing_Button_Endpoint::format_sharing_button($ss, $updated_service);
     }
 }
开发者ID:moushegh,项目名称:blog-source-configs,代码行数:83,代码来源:class.wpcom-json-api-sharing-buttons-endpoint.php

示例4: update_module


//.........这里部分代码省略.........
                 $error = $updated->get_error_message();
             }
             break;
         case 'show_headline':
         case 'show_thumbnails':
             $grouped_options = $grouped_options_current = Jetpack_Options::get_option('relatedposts');
             $grouped_options[$option] = $value;
             // If option value was the same, consider it done.
             $updated = $grouped_options_current != $grouped_options ? Jetpack_Options::update_option('relatedposts', $grouped_options) : true;
             break;
         case 'google':
         case 'bing':
         case 'pinterest':
             $grouped_options = $grouped_options_current = get_option('verification_services_codes');
             $grouped_options[$option] = $value;
             // If option value was the same, consider it done.
             $updated = $grouped_options_current != $grouped_options ? update_option('verification_services_codes', $grouped_options) : true;
             break;
         case 'sharing_services':
             $sharer = new Sharing_Service();
             // If option value was the same, consider it done.
             $updated = $value != $sharer->get_blog_services() ? $sharer->set_blog_services($value['visible'], $value['hidden']) : true;
             break;
         case 'button_style':
         case 'sharing_label':
         case 'show':
             $sharer = new Sharing_Service();
             $grouped_options = $sharer->get_global_options();
             $grouped_options[$option] = $value;
             $updated = $sharer->set_global_options($grouped_options);
             break;
         case 'custom':
             $sharer = new Sharing_Service();
             $updated = $sharer->new_service(stripslashes($value['sharing_name']), stripslashes($value['sharing_url']), stripslashes($value['sharing_icon']));
             // Return new custom service
             $response[$option] = $updated;
             break;
         case 'sharing_delete_service':
             $sharer = new Sharing_Service();
             $updated = $sharer->delete_service($value);
             break;
         case 'jetpack-twitter-cards-site-tag':
             $value = trim(ltrim(strip_tags($value), '@'));
             $updated = get_option($option) !== $value ? update_option($option, $value) : true;
             break;
         case 'onpublish':
         case 'onupdate':
         case 'Bias Language':
         case 'Cliches':
         case 'Complex Expression':
         case 'Diacritical Marks':
         case 'Double Negative':
         case 'Hidden Verbs':
         case 'Jargon Language':
         case 'Passive voice':
         case 'Phrases to Avoid':
         case 'Redundant Expression':
         case 'guess_lang':
             if (in_array($option, array('onpublish', 'onupdate'))) {
                 $atd_option = 'AtD_check_when';
             } elseif ('guess_lang' == $option) {
                 $atd_option = 'AtD_guess_lang';
                 $option = 'true';
             } else {
                 $atd_option = 'AtD_options';
             }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:67,代码来源:class.core-rest-api-endpoints.php


注:本文中的Sharing_Service::new_service方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。