__("PrintNode", XC_WOO_CLOUD)); $sections = $this->insertValueAtPosition($sections, $new_sections, 1); return $sections; } public function printnode_section_options( $settings,$current_section,$id ){ $id = $id."_".$current_section; if($current_section == 'printnode'){ $settings = array( 'section_title' => array( 'name' => __( 'PrintNode', XC_WOO_CLOUD ), 'type' => 'title', 'desc' => __('Configure PrintNode Here', XC_WOO_CLOUD), 'id' => $id.'_section_title' ), 'api' => array( 'name' => __( 'PrintNode API Key', XC_WOO_CLOUD ), 'type' => 'text', 'default' => '', 'desc' => __( 'PrintNode Api Key', XC_WOO_CLOUD ), 'id' => $id.'_api' ), 'section_end' => array( 'type' => 'sectionend', 'id' => $id.'_section_end' ) ); } return $settings; } public function insertValueAtPosition($arr, $insertedArray, $position) { $i = 0; $new_array=array(); foreach ($arr as $key => $value) { if ($i == $position) { foreach ($insertedArray as $ikey => $ivalue) { $new_array[$ikey] = $ivalue; } } $new_array[$key] = $value; $i++; } return $new_array; } public function get_printers(){ $api_key = get_option('xc_woo_cloud_printnode_api'); if(!empty($api_key)){ try{ $credentials = new PrintNode\Credentials(); $credentials->setApiKey($api_key); $request = new PrintNode\Request($credentials); $printers = $request->getPrinters(); return $printers; }catch(Exception $e){ return new WP_Error( 'broke', __( "Invalid PrintNode API Key", XC_WOO_CLOUD ) ); } } return new WP_Error( 'broke', __( "Invalid PrintNode API Key", XC_WOO_CLOUD ) ); } public function add_action_links($links) { $mylinks = array( 'Cloud Print Options' ); return array_merge($mylinks, $links); } } global $xc_woo_printnode; $xc_woo_printnode = new XC_WOO_PrintNode(); endif;