How to use sloc class

Best Atoum code snippet using sloc

class-loc-config.php

Source:class-loc-config.php Github

copy

Full Screen

...12 */13 public static function init() {14 register_setting(15 'simloc', // settings page16 'sloc_map_provider', // option name17 array(18 'type' => 'string',19 'description' => 'Map Provider',20 'show_in_rest' => false,21 'default' => 'wikimedia',22 )23 );24 register_setting(25 'simloc', // settings page26 'sloc_geo_provider', // option name27 array(28 'type' => 'string',29 'description' => 'Geo Lookup Provider',30 'show_in_rest' => false,31 'default' => 'nominatim',32 )33 );34 register_setting(35 'simloc', // settings page36 'sloc_geolocation_provider', // option name37 array(38 'type' => 'string',39 'description' => 'Geolocation Provider',40 'show_in_rest' => false,41 'default' => 'HTML5',42 )43 );44 register_setting(45 'simloc', // settings page46 'sloc_weather_provider', // option name47 array(48 'type' => 'string',49 'description' => 'Weather Provider',50 'show_in_rest' => false,51 'default' => 'openweathermap',52 )53 );54 register_setting(55 'simloc', // settings page56 'sloc_google_api', // option name57 array(58 'type' => 'string',59 'description' => 'Google Maps API Key',60 'show_in_rest' => false,61 'default' => '',62 )63 );64 register_setting(65 'simloc', // settings page66 'sloc_compass_api', // option name67 array(68 'type' => 'string',69 'description' => 'Compass P3K API Key',70 'show_in_rest' => false,71 'default' => '',72 )73 );74 register_setting(75 'simloc', // settings page76 'sloc_compass_url', // option name77 array(78 'type' => 'string',79 'description' => 'Compass P3K URL',80 'show_in_rest' => false,81 'default' => '',82 )83 );84 register_setting(85 'simloc', // settings page86 'sloc_here_api', // option name87 array(88 'type' => 'string',89 'description' => 'HERE Maps API Key',90 'show_in_rest' => false,91 'default' => '',92 )93 );94 register_setting(95 'simloc', // settings page96 'sloc_here_appid', // option name97 array(98 'type' => 'string',99 'description' => 'Here Maps APP ID',100 'show_in_rest' => false,101 'default' => '',102 )103 );104 register_setting(105 'simloc', // settings page106 'sloc_mapbox_api', // option name107 array(108 'type' => 'string',109 'description' => 'Mapbox Static Maps API Key',110 'show_in_rest' => false,111 'default' => '',112 )113 );114 register_setting(115 'simloc', // settings page116 'sloc_bing_api', // option name117 array(118 'type' => 'string',119 'description' => 'Bing Maps API Key',120 'show_in_rest' => false,121 'default' => '',122 )123 );124 register_setting(125 'simloc', // settings page126 'sloc_mapquest_api', // option name127 array(128 'type' => 'string',129 'description' => 'Mapquest API Key',130 'show_in_rest' => false,131 'default' => '',132 )133 );134 register_setting(135 'simloc', // settings page136 'sloc_darksky_api', // option name137 array(138 'type' => 'string',139 'description' => 'DarkSky API Key',140 'show_in_rest' => false,141 'default' => '',142 )143 );144 register_setting(145 'simloc', // settings page146 'sloc_openweathermap_api', // option name147 array(148 'type' => 'string',149 'description' => 'OpenWeatherMap API Key',150 'show_in_rest' => false,151 'default' => '',152 )153 );154 register_setting(155 'simloc', // settings page156 'sloc_apixu_api', // option name157 array(158 'type' => 'string',159 'description' => 'APIXU API Key',160 'show_in_rest' => false,161 'default' => '',162 )163 );164 register_setting(165 'simloc',166 'sloc_geonames_user',167 array(168 'type' => 'string',169 'description' => 'Geonames User',170 'show_in_rest' => false,171 'default' => '',172 )173 );174 register_setting(175 'simloc',176 'sloc_mapbox_user',177 array(178 'type' => 'string',179 'description' => 'Mapbox User',180 'show_in_rest' => false,181 'default' => 'mapbox',182 )183 );184 register_setting(185 'simloc',186 'sloc_mapbox_style',187 array(188 'type' => 'string',189 'description' => 'Mapbox Style',190 'show_in_rest' => false,191 'default' => 'streets-v10',192 )193 );194 register_setting(195 'simloc',196 'sloc_bing_style',197 array(198 'type' => 'string',199 'description' => 'Bing Map Style',200 'show_in_rest' => false,201 'default' => 'CanvasLight',202 )203 );204 register_setting(205 'simloc',206 'sloc_google_style',207 array(208 'type' => 'string',209 'description' => 'Google Map Style',210 'show_in_rest' => false,211 'default' => 'roadmap',212 )213 );214 register_setting(215 'simloc',216 'sloc_mapquest_style',217 array(218 'type' => 'string',219 'description' => 'Mapquest Map Style',220 'show_in_rest' => false,221 'default' => 'map',222 )223 );224 register_setting(225 'simloc', // settings page226 'sloc_height', // option name227 array(228 'type' => 'number',229 'description' => 'Simple Location Map Height',230 'show_in_rest' => true,231 'default' => 350,232 )233 );234 register_setting(235 'simloc', // settings page236 'sloc_width', // option name237 array(238 'type' => 'number',239 'description' => 'Simple Location Map Width',240 'show_in_rest' => true,241 'default' => 350,242 )243 );244 register_setting(245 'simloc', // settings page246 'sloc_zoom', // option name247 array(248 'type' => 'number',249 'description' => 'Simple Location Map Zoom',250 'show_in_rest' => true,251 'default' => 14,252 )253 );254 register_setting(255 'simloc', // settings page256 'sloc_altitude', // option name257 array(258 'type' => 'number',259 'description' => 'Simple Location Height After Which Altitude would be displayed(in meters)',260 'show_in_rest' => true,261 'default' => 500,262 )263 );264 register_setting(265 'simloc', // settings page266 'geo_public', // option name267 array(268 'type' => 'number',269 'description' => 'Default Setting for Geodata',270 'show_in_rest' => true,271 'default' => 1,272 // WordPress Geodata defaults to public but this allows a global override for new posts273 )274 );275 register_setting(276 'simloc', // settings page277 'sloc_last_report', // option name278 array(279 'type' => 'boolean',280 'description' => 'Update Authors Last Reported Location on New Post',281 'show_in_rest' => true,282 'default' => true,283 // If this is true then each time a post is made with location properties it will update the user location284 )285 );286 register_setting(287 'simloc', // settings page288 'sloc_auto_micropub', // option name289 array(290 'type' => 'boolean',291 'description' => 'Add Location from Geolocation Provider Automatically on Micropub Posts',292 'show_in_rest' => true,293 'default' => false,294 // If this is true then each time a post is made without location it will add it set automatically to private295 )296 );297 register_setting(298 'simloc', // settings page299 'sloc_map_display', // option name300 array(301 'type' => 'boolean',302 'description' => 'Show Maps on Home and Archive Pages. Only on single if false',303 'show_in_rest' => true,304 'default' => false,305 )306 );307 register_setting(308 'simloc', // settings page309 'sloc_measurements', // option name310 array(311 'type' => 'string',312 'description' => 'Units to Display',313 'show_in_rest' => true,314 'default' => self::measurement_default(),315 )316 );317 }318 public static function register_provider( $object ) {319 if ( ! $object instanceof Sloc_Provider ) {320 return false;321 }322 if ( $object instanceof Geo_Provider ) {323 static::$geo[ $object->get_slug() ] = $object;324 } elseif ( $object instanceof Map_Provider ) {325 static::$maps[ $object->get_slug() ] = $object;326 } elseif ( $object instanceof Location_Provider ) {327 static::$location[ $object->get_slug() ] = $object;328 } elseif ( $object instanceof Weather_Provider ) {329 static::$weather[ $object->get_slug() ] = $object;330 }331 return true;332 }333 public static function measurement_default() {334 // I cannot foresee every need for imperial but can cover US335 if ( 'en_US' === get_locale() ) {336 return 'imperial';337 }338 return 'si';339 }340 public static function admin_menu() {341 // If the IndieWeb Plugin is installed use its menu.342 if ( class_exists( 'IndieWeb_Plugin' ) ) {343 $hook = add_submenu_page(344 'indieweb',345 __( 'Simple Location', 'simple-location' ), // page title346 __( 'Location', 'simple-location' ), // menu title347 'manage_options', // access capability348 'simloc',349 array( 'Loc_Config', 'simloc_options' )350 );351 } else {352 $hook = add_options_page(353 '',354 'Simple Location',355 'manage_options',356 'simloc',357 array( 'Loc_Config', 'simloc_options' )358 );359 }360 }361 public static function simloc_options() {362 $posts = get_posts(363 array(364 'meta_query' => array(365 array(366 'key' => 'geo_latitude',367 'compare' => 'NOT EXISTS',368 ),369 array(370 'key' => 'geo_address',371 'compare' => 'NOT EXISTS',372 ),373 array(374 'key' => 'geo_public',375 'compare' => 'EXISTS',376 ),377 ),378 'fields' => 'ids',379 )380 );381 foreach ( $posts as $post_id ) {382 delete_post_meta( $post_id, 'geo_public' );383 }384 ?>385 <div class="wrap">386 <h2><?php esc_html_e( 'Simple Location', 'simple-location' ); ?> </h2>387 <p>388 <?php esc_html_e( 'API Keys and Settings for Simple Location', 'simple-location' ); ?>389 </p><hr />390 <form method="post" action="options.php">391 <?php392 settings_fields( 'simloc' );393 do_settings_sections( 'simloc' );394 submit_button();395 ?>396 </form>397 </div>398 <?php399 }400 public static function admin_init() {401 $map_provider = get_option( 'sloc_map_provider' );402 $weather_provider = get_option( 'sloc_weather_provider' );403 $geo_provider = get_option( 'sloc_geo_provider' );404 $location_provider = get_option( 'sloc_geolocation_provider' );405 add_settings_section(406 'sloc_general',407 __( 'General Settings', 'simple-location' ),408 array( 'Loc_Config', 'sloc_general_settings' ),409 'simloc'410 );411 add_settings_field(412 'geo_public', // id413 __( 'Default Display for Location', 'simple-location' ), // setting title414 array( 'Loc_Config', 'provider_callback' ), // display callback415 'simloc', // settings page416 'sloc_general', // settings section417 array(418 'label_for' => 'geo_public',419 'providers' => self::geo_public(),420 )421 );422 add_settings_field(423 'sloc_last_report', // id424 __( 'Update Author Last Reported Location on New Post', 'simple-location' ), // setting title425 array( 'Loc_Config', 'checkbox_callback' ), // display callback426 'simloc', // settings page427 'sloc_general', // settings section428 array(429 'label_for' => 'sloc_last_report',430 )431 );432 add_settings_field(433 'sloc_map_display', // id434 __( 'Show Maps on Home and Archive Pages Not Just Single Posts', 'simple-location' ), // setting title435 array( 'Loc_Config', 'checkbox_callback' ), // display callback436 'simloc', // settings page437 'sloc_general', // settings section438 array(439 'label_for' => 'sloc_map_display',440 )441 );442 add_settings_field(443 'sloc_auto_micropub', // id444 __( 'Automatically lookup location from supported geolocation provider for Micropub posts', 'simple-location' ), // setting title445 array( 'Loc_Config', 'checkbox_callback' ), // display callback446 'simloc', // settings page447 'sloc_general', // settings section448 array(449 'label_for' => 'sloc_auto_micropub',450 )451 );452 add_settings_field(453 'sloc_measurements', // id454 __( 'Unit of Measure', 'simple-location' ), // setting title455 array( 'Loc_Config', 'measure_callback' ), // display callback456 'simloc', // settings page457 'sloc_general', // settings section458 array(459 'label_for' => 'sloc_measurements',460 )461 );462 add_settings_section(463 'sloc_providers',464 __( 'Provider Settings', 'simple-location' ),465 array( 'Loc_Config', 'sloc_provider_settings' ),466 'simloc'467 );468 add_settings_field(469 'sloc_map_provider', // id470 __( 'Map Provider', 'simple-location' ), // setting title471 array( 'Loc_Config', 'provider_callback' ), // display callback472 'simloc', // settings page473 'sloc_providers', // settings section474 array(475 'label_for' => 'sloc_map_provider',476 'description' => __( 'Provides Static Map Images', 'simple-location' ),477 'providers' => self::map_providers(),478 )479 );480 add_settings_field(481 'sloc_geo_provider', // id482 __( 'Geo Provider', 'simple-location' ), // setting title483 array( 'Loc_Config', 'provider_callback' ), // display callback484 'simloc', // settings page485 'sloc_providers', // settings section486 array(487 'label_for' => 'sloc_geo_provider',488 'description' => __( 'Looking up an address from coordinates or vice versa', 'simple-location' ),489 'providers' => self::geo_providers(),490 )491 );492 add_settings_field(493 'sloc_geolocation_provider', // id494 __( 'Geolocation Provider', 'simple-location' ), // setting title495 array( 'Loc_Config', 'provider_callback' ), // display callback496 'simloc', // settings page497 'sloc_providers', // settings section498 array(499 'label_for' => 'sloc_geolocation_provider',500 'description' => __( 'By default this uses your browser to lookup your location but you can alternatively tap into a service to get your current location, perhaps from your phone', 'simple-location' ),501 'providers' => self::geolocation_providers(),502 )503 );504 add_settings_field(505 'sloc_weather_provider', // id506 __( 'Weather Provider', 'simple-location' ), // setting title507 array( 'Loc_Config', 'provider_callback' ), // display callback508 'simloc', // settings page509 'sloc_providers', // settings section510 array(511 'label_for' => 'sloc_weather_provider',512 'description' => __( 'Retrieves Weather Data about a Location', 'simple-location' ),513 'providers' => self::weather_providers(),514 )515 );516 add_settings_section(517 'sloc_map',518 __( 'Map Settings', 'simple-location' ),519 array( 'Loc_Config', 'sloc_map_settings' ),520 'simloc'521 );522 add_settings_field(523 'width', // id524 __( 'Default Map Width', 'simple-location' ), // setting title525 array( 'Loc_Config', 'number_callback' ), // display callback526 'simloc', // settings page527 'sloc_map', // settings section528 array(529 'label_for' => 'sloc_width',530 )531 );532 add_settings_field(533 'height', // id534 __( 'Default Map Height', 'simple-location' ), // setting title535 array( 'Loc_Config', 'number_callback' ), // display callback536 'simloc', // settings page537 'sloc_map', // settings section538 array(539 'label_for' => 'sloc_height',540 )541 );542 add_settings_field(543 'zoom', // id544 __( 'Default Map Zoom', 'simple-location' ), // setting title545 array( 'Loc_Config', 'number_callback' ), // display callback546 'simloc', // settings page547 'sloc_map', // settings section548 array(549 'label_for' => 'sloc_zoom',550 )551 );552 add_settings_field(553 'altitude', // id554 __( 'Altitude will Display if Above This Height(in meters)', 'simple-location' ), // setting title555 array( 'Loc_Config', 'number_callback' ), // display callback556 'simloc', // settings page557 'sloc_map', // settings section558 array(559 'label_for' => 'sloc_altitude',560 )561 );562 add_settings_field(563 'googlestyle', // id564 __( 'Google Style', 'simple-location' ),565 array( 'Loc_Config', 'style_callback' ),566 'simloc',567 'sloc_map',568 array(569 'label_for' => 'sloc_google_style',570 'provider' => new Map_Provider_Google(),571 'class' => ( 'google' === $map_provider ) ? '' : 'hidden',572 )573 );574 add_settings_field(575 'bingstyle', // id576 __( 'Bing Style', 'simple-location' ),577 array( 'Loc_Config', 'style_callback' ),578 'simloc',579 'sloc_map',580 array(581 'label_for' => 'sloc_bing_style',582 'provider' => new Map_Provider_Bing(),583 'class' => ( 'bing' === $map_provider ) ? '' : 'hidden',584 )585 );586 add_settings_field(587 'mapboxuser', // id588 __( 'Mapbox User', 'simple-location' ),589 array( 'Loc_Config', 'string_callback' ),590 'simloc',591 'sloc_map',592 array(593 'label_for' => 'sloc_mapbox_user',594 'class' => ( 'mapbox' === $map_provider ) ? '' : 'hidden',595 )596 );597 add_settings_field(598 'mapboxstyle', // id599 __( 'Mapbox Style', 'simple-location' ),600 array( 'Loc_Config', 'style_callback' ),601 'simloc',602 'sloc_map',603 array(604 'label_for' => 'sloc_mapbox_style',605 'provider' => new Map_Provider_Mapbox(),606 'class' => ( 'mapbox' === $map_provider ) ? '' : 'hidden',607 )608 );609 add_settings_field(610 'mapqueststyle', // id611 __( 'MapQuest Style', 'simple-location' ),612 array( 'Loc_Config', 'style_callback' ),613 'simloc',614 'sloc_map',615 array(616 'label_for' => 'sloc_mapquest_style',617 'provider' => new Map_Provider_Mapquest(),618 'class' => ( 'mapquest' === $map_provider ) ? '' : 'hidden',619 )620 );621 add_settings_section(622 'sloc_weather',623 __( 'Weather Settings', 'simple-location' ),624 array( 'Loc_Config', 'sloc_weather_settings' ),625 'simloc'626 );627 add_settings_section(628 'sloc_providers',629 __( 'Providers', 'simple-location' ),630 array( 'Loc_Config', 'sloc_provider_settings' ),631 'simloc'632 );633 add_settings_section(634 'sloc_api',635 __( 'API Keys', 'simple-location' ),636 array( 'Loc_Config', 'sloc_api_settings' ),637 'simloc'638 );639 add_settings_field(640 'geonamesuser', // id641 __( 'Geonames User', 'simple-location' ),642 array( 'Loc_Config', 'string_callback' ),643 'simloc',644 'sloc_map',645 array(646 'label_for' => 'sloc_geonames_user',647 'class' => ( 'geonames' === $geo_provider ) ? '' : 'hidden',648 )649 );650 add_settings_field(651 'apixuapi', // id652 __( 'APIXU API Key', 'simple-location' ), // setting title653 array( 'Loc_Config', 'string_callback' ), // display callback654 'simloc', // settings page655 'sloc_api', // settings section656 array(657 'label_for' => 'sloc_apixu_api',658 'class' => ( 'apixu' === $weather_provider ) ? '' : 'hidden',659 )660 );661 add_settings_field(662 'hereapi', // id663 __( 'HERE API Key', 'simple-location' ), // setting title664 array( 'Loc_Config', 'string_callback' ), // display callback665 'simloc', // settings page666 'sloc_api', // settings section667 array(668 'label_for' => 'sloc_here_api',669 'class' => ( 'here' === $map_provider ) ? '' : 'hidden',670 )671 );672 add_settings_field(673 'hereapp', // id674 __( 'HERE Application ID', 'simple-location' ), // setting title675 array( 'Loc_Config', 'string_callback' ), // display callback676 'simloc', // settings page677 'sloc_api', // settings section678 array(679 'label_for' => 'sloc_here_appid',680 'class' => ( 'here' === $map_provider ) ? '' : 'hidden',681 )682 );683 add_settings_field(684 'mapquestapi', // id685 __( 'MapQuest API Key', 'simple-location' ), // setting title686 array( 'Loc_Config', 'string_callback' ), // display callback687 'simloc', // settings page688 'sloc_api', // settings section689 array(690 'label_for' => 'sloc_mapquest_api',691 'class' => ( 'mapquest' === $map_provider || 'mapquest' === $geo_provider ) ? '' : 'hidden',692 )693 );694 add_settings_field(695 'googleapi', // id696 __( 'Google Maps API Key', 'simple-location' ), // setting title697 array( 'Loc_Config', 'string_callback' ), // display callback698 'simloc', // settings page699 'sloc_api', // settings section700 array(701 'label_for' => 'sloc_google_api',702 'class' => ( 'google' === $map_provider || 'google' === $geo_provider ) ? '' : 'hidden',703 )704 );705 add_settings_field(706 'bingapi', // id707 __( 'Bing API Key', 'simple-location' ), // setting title708 array( 'Loc_Config', 'string_callback' ), // display callback709 'simloc', // settings page710 'sloc_api', // settings section711 array(712 'label_for' => 'sloc_bing_api',713 'class' => ( 'bing' === $map_provider || 'bing' === $geo_provider ) ? '' : 'hidden',714 )715 );716 add_settings_field(717 'mapboxapi', // id718 __( 'Mapbox API Key', 'simple-location' ), // setting title719 array( 'Loc_Config', 'string_callback' ), // display callback720 'simloc', // settings page721 'sloc_api', // settings section722 array(723 'label_for' => 'sloc_mapbox_api',724 'class' => ( 'mapbox' === $map_provider ) ? '' : 'hidden',725 )726 );727 add_settings_field(728 'sloc_darksky_api', // id729 __( 'Dark Sky API Key', 'simple-location' ), // setting title730 array( 'Loc_Config', 'string_callback' ), // display callback731 'simloc', // settings page732 'sloc_api', // settings section733 array(734 'label_for' => 'sloc_darksky_api',735 'class' => ( 'darksky' === $weather_provider ) ? '' : 'hidden',736 )737 );738 add_settings_field(739 'openweatherapi', // id740 __( 'OpenWeatherMap API Key', 'simple-location' ), // setting title741 array( 'Loc_Config', 'string_callback' ), // display callback742 'simloc', // settings page743 'sloc_api', // settings section744 array(745 'label_for' => 'sloc_openweathermap_api',746 'class' => ( 'openweathermap' === $weather_provider ) ? '' : 'hidden',747 )748 );749 add_settings_field(750 'compassapi', // id751 __( 'Compass API Key', 'simple-location' ), // setting title752 array( 'Loc_Config', 'string_callback' ), // display callback753 'simloc', // settings page754 'sloc_api', // settings section755 array(756 'label_for' => 'sloc_compass_api',757 'class' => ( 'compass' === $location_provider ) ? '' : 'hidden',758 )759 );760 add_settings_field(761 'compassurl', // id762 __( 'Compass URL', 'simple-location' ), // setting title763 array( 'Loc_Config', 'string_callback' ), // display callback764 'simloc', // settings page765 'sloc_api', // settings section766 array(767 'label_for' => 'sloc_compass_url',768 'class' => ( 'compass' === $location_provider ) ? '' : 'hidden',769 )770 );771 }772 public static function checkbox_callback( array $args ) {773 $name = $args['label_for'];774 $checked = get_option( $name );775 printf( '<input name="%1s" type="hidden" value="0" />', $name ); // phpcs:ignore776 printf( '<input name="%1s" type="checkbox" value="1" %2s />', $name, checked( 1, $checked, false ) ); // phpcs:ignore777 }778 public static function number_callback( array $args ) {779 $name = $args['label_for'];780 printf( '<input name="%1s" type="number" min="0" step="1" size="4" class="small-text" value="%2s" />', $name, get_option( $name ) ); // phpcs:ignore781 }782 public static function string_callback( array $args ) {783 $name = $args['label_for'];784 if ( ! isset( $args['type'] ) ) {785 $args['type'] = 'text';786 }787 printf( '<input name="%1s" size="50" autocomplete="off" class="regular-text" type="%2s" value="%3s" />', $name, esc_attR( $args['type'] ), get_option( $name ) ); // phpcs:ignore788 }789 public static function provider_callback( $args ) {790 $name = $args['label_for'];791 $description = ifset( $args['description'], '' );792 $text = get_option( $name );793 $providers = $args['providers'];794 if ( count( $providers ) > 1 ) {795 printf( '<select name="%1$s">', esc_attr( $name ) );796 foreach ( $providers as $key => $value ) {797 printf( '<option value="%1$s" %2$s>%3$s</option>', $key, selected( $text, $key ), $value ); // phpcs:ignore798 }799 echo '</select>';800 echo '<p class="description">' . esc_html( $description ) . '</p>';801 echo '<br /><br />';802 } else {803 printf( '<input name="%1$s" type="radio" id="%1$s" value="%2$s" checked /><span>%3$s</span>', esc_attr( $name ), esc_attr( key( $providers ) ), esc_html( reset( $providers ) ) );804 }805 }806 public static function geo_public() {807 return WP_Geo_Data::geo_public();808 }809 public static function map_providers() {810 $return = array();811 foreach ( static::$maps as $map ) {812 $return[ $map->get_slug() ] = esc_html( $map->get_name() );813 }814 return $return;815 }816 public static function geo_providers() {817 $return = array();818 foreach ( static::$geo as $g ) {819 $return[ $g->get_slug() ] = esc_html( $g->get_name() );820 }821 return $return;822 }823 public static function geolocation_providers() {824 $return = array(825 'HTML5' => __( 'HTML5 Browser Geolocation (requires HTTPS)', 'simple-location' ),826 );827 foreach ( static::$location as $location ) {828 $return[ $location->get_slug() ] = esc_html( $location->get_name() );829 }830 return $return;831 }832 public static function weather_providers( $station = false ) {833 $return = array();834 foreach ( static::$weather as $weather ) {835 if ( ! $station ) {836 $return[ $weather->get_slug() ] = esc_html( $weather->get_name() );837 } elseif ( $weather->is_station() ) {838 $return[ $weather->get_slug() ] = esc_html( $weather->get_name() );839 }840 }841 return $return;842 }843 public static function measure_callback( array $args ) {844 $text = get_option( 'sloc_measurements' );845 echo '<select name="sloc_measurements">';846 printf( '<option value="si" %1$s >%2$s</option>', selected( $text, 'si', false ), __( 'International(SI)', 'simple-location' ) ); // phpcs:ignore847 printf( '<option value="imperial" %1$s >%2$s</option>', selected( $text, 'imperial', false ), __( 'Imperial', 'simple-location' ) ); // phpcs:ignore848 echo '</select><br /><br />';849 }850 public static function style_callback( array $args ) {851 $name = $args['label_for'];852 $provider = $args['provider'];853 $styles = $provider->get_styles();854 if ( is_wp_error( $styles ) ) {855 echo esc_html( $styles->get_error_message() );856 return;857 }858 $text = get_option( $name );859 echo '<select name="' . esc_attr( $name ) . '">';860 foreach ( $styles as $key => $value ) {861 echo '<option value="' . $key . '" ' . selected( $text, $key ) . '>' . esc_html( $value ) . '</option>'; // phpcs:ignore862 }863 echo '</select><br /><br />';864 }865 public static function sloc_general_settings() {866 }867 public static function sloc_provider_settings() {868 esc_html_e( 'Simple Location Depends on External Services', 'simple-location' );869 }870 public static function sloc_map_settings() {871 }872 public static function sloc_weather_settings() {873 }874 public static function sloc_api_settings() {875 esc_html_e( 'API keys are required for most services.', 'simple-location' );876 }877 public static function map_provider() {878 $option = get_option( 'sloc_map_provider' );879 if ( isset( static::$maps[ $option ] ) ) {880 return static::$maps[ $option ];881 }882 return null;883 }884 public static function geo_provider() {885 $option = get_option( 'sloc_geo_provider' );886 if ( isset( static::$geo[ $option ] ) ) {887 return static::$geo[ $option ];888 }889 return null;890 }891 public static function geolocation_provider( $provider = null ) {892 if ( ! $provider ) {893 $provider = get_option( 'sloc_geolocation_provider' );894 }895 if ( 'HTML5' === $provider ) {896 return null;897 }898 if ( isset( static::$location [ $provider ] ) ) {899 return static::$location[ $provider ];900 }901 return null;902 }903 public static function weather_provider( $provider = null ) {904 if ( ! $provider ) {905 $provider = get_option( 'sloc_weather_provider' );906 }907 if ( isset( static::$weather[ $provider ] ) ) {908 return static::$weather[ $provider ];909 }910 return null;911 }912}913function register_sloc_provider( $object ) {914 return Loc_Config::register_provider( $object );915}...

Full Screen

Full Screen

StockManagementController.php

Source:StockManagementController.php Github

copy

Full Screen

...60 {61 }62 public function getSlocApi($id){63 $data = array();64 $sloc = StorageLocation::where('id',$id)->first();65 $slocDetails = StorageLocationDetail::where('storage_location_id',$sloc->id)->with('material.uom','goodsReceiptDetail.goodsReceipt')->get();66 $data['sloc'] = $sloc;67 $data['slocDetail'] = $slocDetails;68 $inventory_value = 0;69 $inventory_qty = 0;70 foreach($slocDetails as $slocDetail){71 $inventory_value += $slocDetail->value * $slocDetail->quantity;72 $inventory_qty += $slocDetail->quantity;73 $received_date = date_create($slocDetail->goodsReceiptDetail->received_date);74 $now = date_create(date("Y-m-d"));75 $aging = date_diff($now,$received_date);76 $slocDetail->aging = $aging->days;77 }78 79 $inventory_value = number_format($inventory_value,2);80 $inventory_qty = number_format($inventory_qty,2);81 $data['sloc'] = $sloc;82 $data['slocDetail'] = $slocDetails;83 $data['slocValue'] = $inventory_value;84 $data['slocQuantity'] = $inventory_qty;85 return response($data, Response::HTTP_OK);86 }87 public function getWarehouseInfoSM($id){88 $data = array();89 $warehouse = Warehouse::where('id',$id)->first();90 $slocs = $warehouse->storageLocations;91 $sloc_ids = $slocs->pluck('id')->toArray();92 $sloc_details = StorageLocationDetail::whereIn('storage_location_id',$sloc_ids);93 $inventory_value = DB::table('mst_storage_location_detail')94 ->join('mst_material', 'mst_material.id', '=', 'mst_storage_location_detail.material_id')95 ->select(DB::raw('sum(mst_storage_location_detail.quantity*mst_material.cost_standard_price) AS sum'))96 ->whereIn('mst_storage_location_detail.storage_location_id', $sloc_ids)97 ->first()->sum;98 // $inventory_value = 0;99 $inventory_qty = $sloc_details->sum('quantity');100 // foreach($slocs as $sloc){101 // $slocDetails = $sloc->storageLocationDetails;102 // foreach($slocDetails as $slocDetail){103 // $inventory_value += $slocDetail->material->cost_standard_price * $slocDetail->quantity;104 // $inventory_qty += $slocDetail->quantity;105 // }106 // }107 $inventory_value = number_format($inventory_value,2);108 $inventory_qty = number_format($inventory_qty,2);109 $data['sloc'] = $slocs;110 $data['warehouseValue'] = $inventory_value;111 $data['warehouseQuantity'] = $inventory_qty;112 return response($data, Response::HTTP_OK);113 }114 public function getWarehouseStockSM($id){115 $warehouse = Warehouse::where('id',$id)->first();116 $slocs = $warehouse->storageLocations;117 $sloc_ids = $slocs->pluck('id')->toArray();118 $sloc_details = StorageLocationDetail::whereIn('storage_location_id',$sloc_ids)->with('material','material.uom')->get();119 return response($sloc_details, Response::HTTP_OK);120 }121 public function getStockInfoSM(){122 $data = array();123 $stocks = Stock::all();124 $inventory_value = 0;125 $inventory_qty = 0;126 $reserved_inventory_qty = 0;127 $available_qty = 0;128 foreach($stocks as $stock){129 $inventory_value += $stock->material->cost_standard_price * $stock->quantity;130 $inventory_qty += $stock->quantity;131 $reserved_inventory_qty += $stock->reserved;132 $available_qty += ($stock->quantity)-($stock->reserved);133 }...

Full Screen

Full Screen

sloc

Using AI Code Generation

copy

Full Screen

1$script->addTestsFromDirectory(__DIR__ . '/tests/units/classes/');2$script->addTestsFromDirectory(__DIR__ . '/tests/units/classes/');3$script->addTestsFromDirectory(__DIR__ . '/tests/units/classes/');4$script->addTestsFromDirectory(__DIR__ . '/tests/units/classes/');5$script->addTestsFromDirectory(__DIR__ . '/tests/units/classes/');6$script->addTestsFromDirectory(__DIR__ . '/tests/units/classes/');7$script->addTestsFromDirectory(__DIR__ . '/tests/units/classes/');8$script->addTestsFromDirectory(__DIR__ . '/tests/units/classes/');9$script->addTestsFromDirectory(__DIR__ . '/tests/units/classes/');10$script->addTestsFromDirectory(__DIR__ . '/tests/units/classes/');11$script->addTestsFromDirectory(__DIR__ . '/tests/units/classes/');12$script->addTestsFromDirectory(__DIR__ . '/tests/units/classes/');13$script->addTestsFromDirectory(__DIR__ . '/tests/units/classes/');14$script->addTestsFromDirectory(__DIR__ . '/tests/units/classes/

Full Screen

Full Screen

sloc

Using AI Code Generation

copy

Full Screen

1require_once 'vendor/autoload.php';2use mageekguy\atoum\reports\realtime\cli;3use mageekguy\atoum\reports\realtime\cli\progressBar;4use mageekguy\atoum\reports\realtime\cli\progressBar\cliColorizer;5use mageekguy\atoum\reports\realtime\cli\progressBar\cliColorizer\style;6use mageekguy\atoum\reports\realtime\cli\progressBar\cliColorizer\color;7use mageekguy\atoum\reports\realtime\cli\progressBar\cliColorizer\background;8use mageekguy\atoum\reports\realtime\cli\progressBar\cliColorizer\decorator;9use mageekguy\atoum\reports\realtime\cli\progressBar\cliColorizer\decorator\blink;10use mageekguy\atoum\reports\realtime\cli\progressBar\cliColorizer\decorator\bold;11use mageekguy\atoum\reports\realtime\cli\progressBar\cliColorizer\decorator\conceal;12use mageekguy\atoum\reports\realtime\cli\progressBar\cliColorizer\decorator\crossedOut;13use mageekguy\atoum\reports\realtime\cli\progressBar\cliColorizer\decorator\doubleUnderline;14use mageekguy\atoum\reports\realtime\cli\progressBar\cliColorizer\decorator\flash;15use mageekguy\atoum\reports\realtime\cli\progressBar\cliColorizer\decorator\frame;16use mageekguy\atoum\reports\realtime\cli\progressBar\cliColorizer\decorator\hide;17use mageekguy\atoum\reports\realtime\cli\progressBar\cliColorizer\decorator\overline;18use mageekguy\atoum\reports\realtime\cli\progressBar\cliColorizer\decorator\reverse;

Full Screen

Full Screen

sloc

Using AI Code Generation

copy

Full Screen

1require_once 'vendor/autoload.php';2use mageekguy\atoum\cli;3$script = new cli\script();4$script->addDefaultReport();5$runner = new \mageekguy\atoum\runner();6$runner->addTestsFromDirectory('tests/units/');7$runner->setBootstrapFile('bootstrap.php');8$runner->setTestClassesDirectory('tests/units/');9$runner->run($script);10require_once 'vendor/autoload.php';11use mageekguy\atoum\cli;12$script = new cli\script();13$script->addDefaultReport();14$runner = new \mageekguy\atoum\runner();15$runner->addTestsFromDirectory('tests/units/');16$runner->setBootstrapFile('bootstrap.php');17$runner->setTestClassesDirectory('tests/units/');18$runner->run($script);19require_once 'vendor/autoload.php';20use mageekguy\atoum\cli;21$script = new cli\script();22$script->addDefaultReport();23$runner = new \mageekguy\atoum\runner();24$runner->addTestsFromDirectory('tests/units/');25$runner->setBootstrapFile('bootstrap.php');26$runner->setTestClassesDirectory('tests/units/');27$runner->run($script);28require_once 'vendor/autoload.php';29use mageekguy\atoum\cli;30$script = new cli\script();31$script->addDefaultReport();32$runner = new \mageekguy\atoum\runner();33$runner->addTestsFromDirectory('tests/units/');34$runner->setBootstrapFile('bootstrap.php');35$runner->setTestClassesDirectory('tests/units/');36$runner->run($script);37require_once 'vendor/autoload.php';38use mageekguy\atoum\cli;39$script = new cli\script();

Full Screen

Full Screen

sloc

Using AI Code Generation

copy

Full Screen

1$script->addTestsFromDirectory(__DIR__ . '/tests/units');2$script->addDefaultReport();3$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\cli());4$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\badge());5$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\text());6$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\phpunit());7$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\cobertura());8$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\coveralls());9$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\sonar());10$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\travis());11$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\xunit());12$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\clover());13$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\junit());14$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\csv());15$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\html());16$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\markdown());17$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\teamcity());18$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\json());19$runner->addExtension(new \mageekguy\atoum\report\fields\runner\result\yaml());20$runner->addExtension(new \mageekguy\atoum\report\fields\runner\

Full Screen

Full Screen

sloc

Using AI Code Generation

copy

Full Screen

1{2 public function testSloc()3 {4 ->variable($this->getTestedClassName())5 ->isNull()6 ->if($this->newTestedInstance)7 ->string($this->testedInstance->getTestedClassName())8 ->isEqualTo('mageekguy\atoum')9 ;10 }11}12{13 public function testSloc()14 {15 ->variable($this->getTestedClassName())16 ->isNull()17 ->if($this->newTestedInstance)18 ->string($this->testedInstance->getTestedClassName())19 ->isEqualTo('mageekguy\atoum')20 ;21 }22}23{24 public function testSloc()25 {26 ->variable($this->getTestedClassName())27 ->isNull()28 ->if($this->newTestedInstance)29 ->string($this->testedInstance->getTestedClassName())30 ->isEqualTo('mageekguy\atoum')31 ;32 }33}34{35 public function testSloc()36 {37 ->variable($this->getTestedClassName())38 ->isNull()39 ->if($this->newTestedInstance)40 ->string($this->testedInstance->getTestedClassName())41 ->isEqualTo('mageekguy\atoum')42 ;43 }44}45{46 public function testSloc()47 {48 ->variable($this->getTestedClassName())49 ->isNull()50 ->if($this->newTested

Full Screen

Full Screen

sloc

Using AI Code Generation

copy

Full Screen

1use Sloc\Sloc;2use Sloc\Sloc;3use Sloc\Sloc;4use Sloc\Sloc;5use Sloc\Sloc;6use Sloc\Sloc;7use Sloc\Sloc;8use Sloc\Sloc;9use Sloc\Sloc;10use Sloc\Sloc;11use Sloc\Sloc;12use Sloc\Sloc;13use Sloc\Sloc;14use Sloc\Sloc;15use Sloc\Sloc;16use Sloc\Sloc;17use Sloc\Sloc;18use Sloc\Sloc;19use Sloc\Sloc;20use Sloc\Sloc;

Full Screen

Full Screen

sloc

Using AI Code Generation

copy

Full Screen

1require 'vendor/autoload.php';2use atoum\atoum;3$test = new atoum\test();4$test->setCodeCoverage(new atoum\code\coverage\driver\blackfire());5$test->run();6require 'vendor/autoload.php';7use atoum\atoum;8$test = new atoum\test();9$test->setCodeCoverage(new atoum\code\coverage\driver\blackfire());10$test->run();11require 'vendor/autoload.php';12use atoum\atoum;13$test = new atoum\test();14$test->setCodeCoverage(new atoum\code\coverage\driver\blackfire());15$test->run();16require 'vendor/autoload.php';17use atoum\atoum;18$test = new atoum\test();19$test->setCodeCoverage(new atoum\code\coverage\driver\blackfire());20$test->run();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful